Skip to content

Commit ef2ef92

Browse files
committed
Auto merge of rust-lang#81047 - glittershark:stabilize-cmp-min-max-by, r=kodraus
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. Closes: rust-lang#64460
2 parents e9cdccc + 462f86d commit ef2ef92

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
@@ -1059,16 +1059,14 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
10591059
/// # Examples
10601060
///
10611061
/// ```
1062-
/// #![feature(cmp_min_max_by)]
1063-
///
10641062
/// use std::cmp;
10651063
///
10661064
/// assert_eq!(cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 1);
10671065
/// assert_eq!(cmp::min_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
10681066
/// ```
10691067
#[inline]
10701068
#[must_use]
1071-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1069+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
10721070
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
10731071
match compare(&v1, &v2) {
10741072
Ordering::Less | Ordering::Equal => v1,
@@ -1083,16 +1081,14 @@ pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
10831081
/// # Examples
10841082
///
10851083
/// ```
1086-
/// #![feature(cmp_min_max_by)]
1087-
///
10881084
/// use std::cmp;
10891085
///
10901086
/// assert_eq!(cmp::min_by_key(-2, 1, |x: &i32| x.abs()), 1);
10911087
/// assert_eq!(cmp::min_by_key(-2, 2, |x: &i32| x.abs()), -2);
10921088
/// ```
10931089
#[inline]
10941090
#[must_use]
1095-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1091+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
10961092
pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
10971093
min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
10981094
}
@@ -1125,16 +1121,14 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
11251121
/// # Examples
11261122
///
11271123
/// ```
1128-
/// #![feature(cmp_min_max_by)]
1129-
///
11301124
/// use std::cmp;
11311125
///
11321126
/// assert_eq!(cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
11331127
/// assert_eq!(cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 2);
11341128
/// ```
11351129
#[inline]
11361130
#[must_use]
1137-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1131+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
11381132
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11391133
match compare(&v1, &v2) {
11401134
Ordering::Less | Ordering::Equal => v2,
@@ -1149,16 +1143,14 @@ pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11491143
/// # Examples
11501144
///
11511145
/// ```
1152-
/// #![feature(cmp_min_max_by)]
1153-
///
11541146
/// use std::cmp;
11551147
///
11561148
/// assert_eq!(cmp::max_by_key(-2, 1, |x: &i32| x.abs()), -2);
11571149
/// assert_eq!(cmp::max_by_key(-2, 2, |x: &i32| x.abs()), 2);
11581150
/// ```
11591151
#[inline]
11601152
#[must_use]
1161-
#[unstable(feature = "cmp_min_max_by", issue = "64460")]
1153+
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
11621154
pub fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
11631155
max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
11641156
}

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#![feature(iter_intersperse)]
5858
#![feature(iter_is_partitioned)]
5959
#![feature(iter_order_by)]
60-
#![feature(cmp_min_max_by)]
6160
#![feature(iter_map_while)]
6261
#![feature(const_mut_refs)]
6362
#![feature(const_pin)]

0 commit comments

Comments
 (0)