mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Fix parameter order for _by()
variants of min
/ max
/ minmax
in std::cmp
This commit is contained in:
parent
9e14530c7c
commit
2d2486d2da
@ -1572,7 +1572,7 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
|
||||
if compare(&v2, &v1).is_lt() { v2 } else { v1 }
|
||||
if compare(&v1, &v2).is_le() { v1 } else { v2 }
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
|
||||
if compare(&v2, &v1).is_lt() { v1 } else { v2 }
|
||||
if compare(&v1, &v2).is_gt() { v1 } else { v2 }
|
||||
}
|
||||
|
||||
/// 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]
|
||||
where
|
||||
F: FnOnce(&T, &T) -> Ordering,
|
||||
{
|
||||
if compare(&v2, &v1).is_lt() { [v2, v1] } else { [v1, v2] }
|
||||
if compare(&v1, &v2).is_le() { [v1, v2] } else { [v2, v1] }
|
||||
}
|
||||
|
||||
/// Returns minimum and maximum values with respect to the specified key function.
|
||||
|
Loading…
Reference in New Issue
Block a user