@@ -396,13 +396,13 @@ fn builtin_locals(vm: &VirtualMachine) -> PyDictRef {
396396}
397397
398398fn builtin_max ( vm : & VirtualMachine , args : PyFuncArgs ) -> PyResult {
399- let candidates = if args. args . len ( ) > 1 {
400- args. args . clone ( )
401- } else if args . args . len ( ) == 1 {
402- vm . extract_elements ( & args . args [ 0 ] ) ?
403- } else {
404- // zero arguments means type error:
405- return Err ( vm . new_type_error ( "Expected 1 or more arguments" . to_string ( ) ) ) ;
399+ let candidates = match args. args . len ( ) . cmp ( & 1 ) {
400+ std :: cmp :: Ordering :: Greater => args. args . clone ( ) ,
401+ std :: cmp :: Ordering :: Equal => vm . extract_elements ( & args. args [ 0 ] ) ? ,
402+ std :: cmp :: Ordering :: Less => {
403+ // zero arguments means type error:
404+ return Err ( vm . new_type_error ( "Expected 1 or more arguments" . to_string ( ) ) ) ;
405+ }
406406 } ;
407407
408408 if candidates. is_empty ( ) {
@@ -442,13 +442,13 @@ fn builtin_max(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
442442}
443443
444444fn builtin_min ( vm : & VirtualMachine , args : PyFuncArgs ) -> PyResult {
445- let candidates = if args. args . len ( ) > 1 {
446- args. args . clone ( )
447- } else if args . args . len ( ) == 1 {
448- vm . extract_elements ( & args . args [ 0 ] ) ?
449- } else {
450- // zero arguments means type error:
451- return Err ( vm . new_type_error ( "Expected 1 or more arguments" . to_string ( ) ) ) ;
445+ let candidates = match args. args . len ( ) . cmp ( & 1 ) {
446+ std :: cmp :: Ordering :: Greater => args. args . clone ( ) ,
447+ std :: cmp :: Ordering :: Equal => vm . extract_elements ( & args. args [ 0 ] ) ? ,
448+ std :: cmp :: Ordering :: Less => {
449+ // zero arguments means type error:
450+ return Err ( vm . new_type_error ( "Expected 1 or more arguments" . to_string ( ) ) ) ;
451+ }
452452 } ;
453453
454454 if candidates. is_empty ( ) {
0 commit comments