Skip to content

Commit

Permalink
Auto merge of rust-lang#77872 - Xaeroxe:stabilize-clamp, r=scottmcm
Browse files Browse the repository at this point in the history
Stabilize clamp

Tracking issue: rust-lang#44095

Clamp has been merged and unstable for about a year and a half now. How do we feel about stabilizing this?
  • Loading branch information
bors committed Nov 22, 2020
2 parents 20328b5 + fb6ceac commit 5d5ff84
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
4 changes: 1 addition & 3 deletions library/core/src/cmp.rs
Expand Up @@ -641,14 +641,12 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// # Examples
///
/// ```
/// #![feature(clamp)]
///
/// assert!((-3).clamp(-2, 1) == -2);
/// assert!(0.clamp(-2, 1) == 0);
/// assert!(2.clamp(-2, 1) == 1);
/// ```
#[must_use]
#[unstable(feature = "clamp", issue = "44095")]
#[stable(feature = "clamp", since = "1.50.0")]
fn clamp(self, min: Self, max: Self) -> Self
where
Self: Sized,
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/f32.rs
Expand Up @@ -893,14 +893,13 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(clamp)]
/// assert!((-3.0f32).clamp(-2.0, 1.0) == -2.0);
/// assert!((0.0f32).clamp(-2.0, 1.0) == 0.0);
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
/// assert!((f32::NAN).clamp(-2.0, 1.0).is_nan());
/// ```
#[must_use = "method returns a new number and does not mutate the original value"]
#[unstable(feature = "clamp", issue = "44095")]
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
pub fn clamp(self, min: f32, max: f32) -> f32 {
assert!(min <= max);
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/f64.rs
Expand Up @@ -895,14 +895,13 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(clamp)]
/// assert!((-3.0f64).clamp(-2.0, 1.0) == -2.0);
/// assert!((0.0f64).clamp(-2.0, 1.0) == 0.0);
/// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0);
/// assert!((f64::NAN).clamp(-2.0, 1.0).is_nan());
/// ```
#[must_use = "method returns a new number and does not mutate the original value"]
#[unstable(feature = "clamp", issue = "44095")]
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
pub fn clamp(self, min: f64, max: f64) -> f64 {
assert!(min <= max);
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Expand Up @@ -235,7 +235,6 @@
#![feature(cfg_target_thread_local)]
#![feature(char_error_internals)]
#![feature(char_internals)]
#![feature(clamp)]
#![feature(concat_idents)]
#![feature(const_cstr_unchecked)]
#![feature(const_fn_floating_point_arithmetic)]
Expand Down

0 comments on commit 5d5ff84

Please sign in to comment.