mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Auto merge of #77872 - Xaeroxe:stabilize-clamp, r=scottmcm
Stabilize clamp Tracking issue: https://github.com/rust-lang/rust/issues/44095 Clamp has been merged and unstable for about a year and a half now. How do we feel about stabilizing this?
This commit is contained in:
commit
5d5ff84130
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user