@@ -1572,7 +1572,7 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
1572
1572
#[ must_use]
1573
1573
#[ stable( feature = "cmp_min_max_by" , since = "1.53.0" ) ]
1574
1574
pub fn min_by < T , F : FnOnce ( & T , & T ) -> Ordering > ( v1 : T , v2 : T , compare : F ) -> T {
1575
- if compare ( & v2 , & v1 ) . is_lt ( ) { v2 } else { v1 }
1575
+ if compare ( & v1 , & v2 ) . is_le ( ) { v1 } else { v2 }
1576
1576
}
1577
1577
1578
1578
/// Returns the element that gives the minimum value from the specified function.
@@ -1664,7 +1664,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
1664
1664
#[ must_use]
1665
1665
#[ stable( feature = "cmp_min_max_by" , since = "1.53.0" ) ]
1666
1666
pub fn max_by < T , F : FnOnce ( & T , & T ) -> Ordering > ( v1 : T , v2 : T , compare : F ) -> T {
1667
- if compare ( & v2 , & v1 ) . is_lt ( ) { v1 } else { v2 }
1667
+ if compare ( & v1 , & v2 ) . is_gt ( ) { v1 } else { v2 }
1668
1668
}
1669
1669
1670
1670
/// Returns the element that gives the maximum value from the specified function.
@@ -1767,7 +1767,7 @@ pub fn minmax_by<T, F>(v1: T, v2: T, compare: F) -> [T; 2]
1767
1767
where
1768
1768
F : FnOnce ( & T , & T ) -> Ordering ,
1769
1769
{
1770
- if compare ( & v2 , & v1 ) . is_lt ( ) { [ v2 , v1 ] } else { [ v1 , v2 ] }
1770
+ if compare ( & v1 , & v2 ) . is_le ( ) { [ v1 , v2 ] } else { [ v2 , v1 ] }
1771
1771
}
1772
1772
1773
1773
/// Returns minimum and maximum values with respect to the specified key function.
0 commit comments