Fix documentation and formatting.
This commit is contained in:
@@ -483,7 +483,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns max if self is greater than max, and min if self is less than min.
|
/// Returns max if self is greater than max, and min if self is less than min.
|
||||||
/// Otherwise this will return self. Panics if min > max.
|
/// Otherwise this will return self.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
@@ -494,18 +494,16 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
|||||||
/// assert!(0.clamp(-2, 1) == 0);
|
/// assert!(0.clamp(-2, 1) == 0);
|
||||||
/// assert!(2.clamp(-2, 1) == 1);
|
/// assert!(2.clamp(-2, 1) == 1);
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
/// Panics if min > max.
|
||||||
#[unstable(feature = "clamp", issue = "44095")]
|
#[unstable(feature = "clamp", issue = "44095")]
|
||||||
fn clamp(self, min: Self, max: Self) -> Self
|
fn clamp(self, min: Self, max: Self) -> Self
|
||||||
where Self: Sized {
|
where Self: Sized {
|
||||||
assert!(min <= max);
|
assert!(min <= max);
|
||||||
if self < min {
|
if self < min { min }
|
||||||
min
|
else if self > max { max }
|
||||||
}
|
else { self }
|
||||||
else if self > max {
|
|
||||||
max
|
|
||||||
} else {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1081,7 +1081,7 @@ impl f32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns max if self is greater than max, and min if self is less than min.
|
/// Returns max if self is greater than max, and min if self is less than min.
|
||||||
/// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN.
|
/// Otherwise this returns self.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
@@ -1093,6 +1093,9 @@ impl f32 {
|
|||||||
/// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32);
|
/// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32);
|
||||||
/// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan());
|
/// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan());
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
/// Panics if min > max, min is NaN, or max is NaN.
|
||||||
#[unstable(feature = "clamp", issue = "44095")]
|
#[unstable(feature = "clamp", issue = "44095")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clamp(self, min: f32, max: f32) -> f32 {
|
pub fn clamp(self, min: f32, max: f32) -> f32 {
|
||||||
|
|||||||
@@ -971,7 +971,7 @@ impl f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns max if self is greater than max, and min if self is less than min.
|
/// Returns max if self is greater than max, and min if self is less than min.
|
||||||
/// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN.
|
/// Otherwise this returns self.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
@@ -983,6 +983,9 @@ impl f64 {
|
|||||||
/// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64);
|
/// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64);
|
||||||
/// assert!((NAN).clamp(-2.0f64, 1.0f64).is_nan());
|
/// assert!((NAN).clamp(-2.0f64, 1.0f64).is_nan());
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
/// Panics if min > max, min is NaN, or max is NaN.
|
||||||
#[unstable(feature = "clamp", issue = "44095")]
|
#[unstable(feature = "clamp", issue = "44095")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clamp(self, min: f64, max: f64) -> f64 {
|
pub fn clamp(self, min: f64, max: f64) -> f64 {
|
||||||
|
|||||||
Reference in New Issue
Block a user