Fix f32 examples.

This commit is contained in:
Jacob Kiesel
2017-08-26 17:53:01 -06:00
committed by GitHub
parent f74c5d2e18
commit 61f20f8df0

View File

@@ -1081,15 +1081,17 @@ 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 equals NaN, or max equals NaN. /// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN.
/// ///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(clamp)]
/// use std::f32::NAN;
/// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32);
/// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32);
/// 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) == NAN); /// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan());
/// ``` /// ```
#[unstable(feature = "clamp", issue = "44095")] #[unstable(feature = "clamp", issue = "44095")]
#[inline] #[inline]