Skip to content

Commit 462f86d

Browse files
committed
Stabilize cmp_min_max_by
I would like to propose cmp::{min_by, min_by_key, max_by, max_by_key} for stabilization. These are relatively simple and seemingly uncontroversial functions and have been unchanged in unstable for a while now.
1 parent 76aca66 commit 462f86d

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(bool_to_option)]
3030
#![feature(box_patterns)]
3131
#![feature(box_syntax)]
32-
#![feature(cmp_min_max_by)]
3332
#![feature(const_fn)]
3433
#![feature(const_panic)]
3534
#![feature(core_intrinsics)]

library/core/src/cmp.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -1053,16 +1053,14 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
10531053
/// # Examples
10541054
///
10551055
/// ```
1056-
/// #![feature(cmp_min_max_by)]
1057-
///
10581056
/// use std::cmp;
10591057
///
10601058
/// assert_eq!(cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 1);
10611059
/// assert_eq!(cmp::min_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
10621060
/// ```
10631061
#[inline]
10641062
#[must_use]
1065-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1063+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
10661064
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
10671065
match compare(&v1, &v2) {
10681066
Ordering::Less | Ordering::Equal => v1,
@@ -1077,16 +1075,14 @@ pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
10771075
/// # Examples
10781076
///
10791077
/// ```
1080-
/// #![feature(cmp_min_max_by)]
1081-
///
10821078
/// use std::cmp;
10831079
///
10841080
/// assert_eq!(cmp::min_by_key(-2, 1, |x: &i32| x.abs()), 1);
10851081
/// assert_eq!(cmp::min_by_key(-2, 2, |x: &i32| x.abs()), -2);
10861082
/// ```
10871083
#[inline]
10881084
#[must_use]
1089-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1085+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
10901086
pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
10911087
min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
10921088
}
@@ -1119,16 +1115,14 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
11191115
/// # Examples
11201116
///
11211117
/// ```
1122-
/// #![feature(cmp_min_max_by)]
1123-
///
11241118
/// use std::cmp;
11251119
///
11261120
/// assert_eq!(cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
11271121
/// assert_eq!(cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 2);
11281122
/// ```
11291123
#[inline]
11301124
#[must_use]
1131-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1125+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
11321126
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11331127
match compare(&v1, &v2) {
11341128
Ordering::Less | Ordering::Equal => v2,
@@ -1143,16 +1137,14 @@ pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11431137
/// # Examples
11441138
///
11451139
/// ```
1146-
/// #![feature(cmp_min_max_by)]
1147-
///
11481140
/// use std::cmp;
11491141
///
11501142
/// assert_eq!(cmp::max_by_key(-2, 1, |x: &i32| x.abs()), -2);
11511143
/// assert_eq!(cmp::max_by_key(-2, 2, |x: &i32| x.abs()), 2);
11521144
/// ```
11531145
#[inline]
11541146
#[must_use]
1155-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1147+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
11561148
pub fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
11571149
max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
11581150
}

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#![feature(iter_partition_in_place)]
5151
#![feature(iter_is_partitioned)]
5252
#![feature(iter_order_by)]
53-
#![feature(cmp_min_max_by)]
5453
#![feature(iter_map_while)]
5554
#![feature(const_mut_refs)]
5655
#![feature(const_pin)]

0 commit comments

Comments
 (0)