Skip to content

Commit db5b5f9

Browse files
committed
Revert "Add clamp functions"
This reverts commit c589f86.
1 parent 63f4dab commit db5b5f9

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

src/libcore/cmp.rs

-26
Original file line numberDiff line numberDiff line change
@@ -481,32 +481,6 @@ pub trait Ord: Eq + PartialOrd<Self> {
481481
where Self: Sized {
482482
if self <= other { self } else { other }
483483
}
484-
485-
/// Returns max if self is greater than max, and min if self is less than min.
486-
/// Otherwise this will return self. Panics if min > max.
487-
///
488-
/// # Examples
489-
///
490-
/// ```
491-
/// #![feature(clamp)]
492-
///
493-
/// assert!((-3).clamp(-2, 1) == -2);
494-
/// assert!(0.clamp(-2, 1) == 0);
495-
/// assert!(2.clamp(-2, 1) == 1);
496-
/// ```
497-
#[unstable(feature = "clamp", issue = "44095")]
498-
fn clamp(self, min: Self, max: Self) -> Self
499-
where Self: Sized {
500-
assert!(min <= max);
501-
if self < min {
502-
min
503-
}
504-
else if self > max {
505-
max
506-
} else {
507-
self
508-
}
509-
}
510484
}
511485

512486
#[stable(feature = "rust1", since = "1.0.0")]

src/libstd/f32.rs

-20
Original file line numberDiff line numberDiff line change
@@ -1080,26 +1080,6 @@ impl f32 {
10801080
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
10811081
}
10821082

1083-
/// Returns max if self is greater than max, and min if self is less than min.
1084-
/// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN.
1085-
///
1086-
/// # Examples
1087-
///
1088-
/// ```
1089-
/// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32);
1090-
/// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32);
1091-
/// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32);
1092-
/// ```
1093-
#[unstable(feature = "clamp", issue = "44095")]
1094-
#[inline]
1095-
pub fn clamp(self, min: f32, max: f32) -> f32 {
1096-
assert!(min <= max);
1097-
let mut x = self;
1098-
if x < min { x = min; }
1099-
if x > max { x = max; }
1100-
x
1101-
}
1102-
11031083
/// Raw transmutation to `u32`.
11041084
///
11051085
/// Converts the `f32` into its raw memory representation,

src/libstd/f64.rs

-20
Original file line numberDiff line numberDiff line change
@@ -970,26 +970,6 @@ impl f64 {
970970
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
971971
}
972972

973-
/// Returns max if self is greater than max, and min if self is less than min.
974-
/// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN.
975-
///
976-
/// # Examples
977-
///
978-
/// ```
979-
/// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64);
980-
/// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64);
981-
/// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64);
982-
/// ```
983-
#[unstable(feature = "clamp", issue = "44095")]
984-
#[inline]
985-
pub fn clamp(self, min: f64, max: f64) -> f64 {
986-
assert!(min <= max);
987-
let mut x = self;
988-
if x < min { x = min; }
989-
if x > max { x = max; }
990-
x
991-
}
992-
993973
// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
994974
// because of their non-standard behavior (e.g. log(-n) returns -Inf instead
995975
// of expected NaN).

0 commit comments

Comments
 (0)