Skip to content

Commit 8b96167

Browse files
committed
Revert "Fix documentation and formatting."
This reverts commit 2e34ff7.
1 parent 67283fa commit 8b96167

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/libcore/cmp.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
483483
}
484484

485485
/// Returns max if self is greater than max, and min if self is less than min.
486-
/// Otherwise this will return self.
486+
/// Otherwise this will return self. Panics if min > max.
487487
///
488488
/// # Examples
489489
///
@@ -494,16 +494,18 @@ pub trait Ord: Eq + PartialOrd<Self> {
494494
/// assert!(0.clamp(-2, 1) == 0);
495495
/// assert!(2.clamp(-2, 1) == 1);
496496
/// ```
497-
///
498-
/// # Panics
499-
/// Panics if min > max.
500497
#[unstable(feature = "clamp", issue = "44095")]
501498
fn clamp(self, min: Self, max: Self) -> Self
502499
where Self: Sized {
503500
assert!(min <= max);
504-
if self < min { min }
505-
else if self > max { max }
506-
else { self }
501+
if self < min {
502+
min
503+
}
504+
else if self > max {
505+
max
506+
} else {
507+
self
508+
}
507509
}
508510
}
509511

src/libstd/f32.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ impl f32 {
10811081
}
10821082

10831083
/// Returns max if self is greater than max, and min if self is less than min.
1084-
/// Otherwise this returns self.
1084+
/// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN.
10851085
///
10861086
/// # Examples
10871087
///
@@ -1093,9 +1093,6 @@ impl f32 {
10931093
/// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32);
10941094
/// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan());
10951095
/// ```
1096-
///
1097-
/// # Panics
1098-
/// Panics if min > max, min is NaN, or max is NaN.
10991096
#[unstable(feature = "clamp", issue = "44095")]
11001097
#[inline]
11011098
pub fn clamp(self, min: f32, max: f32) -> f32 {

src/libstd/f64.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl f64 {
971971
}
972972

973973
/// Returns max if self is greater than max, and min if self is less than min.
974-
/// Otherwise this returns self.
974+
/// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN.
975975
///
976976
/// # Examples
977977
///
@@ -983,9 +983,6 @@ impl f64 {
983983
/// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64);
984984
/// assert!((NAN).clamp(-2.0f64, 1.0f64).is_nan());
985985
/// ```
986-
///
987-
/// # Panics
988-
/// Panics if min > max, min is NaN, or max is NaN.
989986
#[unstable(feature = "clamp", issue = "44095")]
990987
#[inline]
991988
pub fn clamp(self, min: f64, max: f64) -> f64 {

0 commit comments

Comments
 (0)