Skip to content

Commit d02cab1

Browse files
committed
Revert "Constify cmp_min_max_by"
This reverts commit 2e7a201.
1 parent 6664087 commit d02cab1

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

library/core/src/cmp.rs

+6-28
Original file line numberDiff line numberDiff line change
@@ -1184,12 +1184,7 @@ pub const fn min<T: ~const Ord + ~const Destruct>(v1: T, v2: T) -> T {
11841184
#[inline]
11851185
#[must_use]
11861186
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1187-
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1188-
pub const fn min_by<T, F: ~const FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
1189-
where
1190-
T: ~const Destruct,
1191-
F: ~const Destruct,
1192-
{
1187+
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11931188
match compare(&v1, &v2) {
11941189
Ordering::Less | Ordering::Equal => v1,
11951190
Ordering::Greater => v2,
@@ -1211,14 +1206,8 @@ where
12111206
#[inline]
12121207
#[must_use]
12131208
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1214-
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1215-
pub const fn min_by_key<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(v1: T, v2: T, mut f: F) -> T
1216-
where
1217-
T: ~const Destruct,
1218-
F: ~const Destruct,
1219-
K: ~const Destruct,
1220-
{
1221-
min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
1209+
pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
1210+
min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
12221211
}
12231212

12241213
/// Compares and returns the maximum of two values.
@@ -1259,12 +1248,7 @@ pub const fn max<T: ~const Ord + ~const Destruct>(v1: T, v2: T) -> T {
12591248
#[inline]
12601249
#[must_use]
12611250
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1262-
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1263-
pub const fn max_by<T, F: ~const FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
1264-
where
1265-
T: ~const Destruct,
1266-
F: ~const Destruct,
1267-
{
1251+
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
12681252
match compare(&v1, &v2) {
12691253
Ordering::Less | Ordering::Equal => v2,
12701254
Ordering::Greater => v1,
@@ -1286,14 +1270,8 @@ where
12861270
#[inline]
12871271
#[must_use]
12881272
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1289-
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1290-
pub const fn max_by_key<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(v1: T, v2: T, mut f: F) -> T
1291-
where
1292-
T: ~const Destruct,
1293-
F: ~const Destruct,
1294-
K: ~const Destruct,
1295-
{
1296-
max_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
1273+
pub fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
1274+
max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
12971275
}
12981276

12991277
// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types

0 commit comments

Comments
 (0)