mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Rollup merge of #106633 - c410-f3r:stabilize-nonzero_bits, r=dtolnay
Stabilize `nonzero_min_max` ## Overall Stabilizes `nonzero_min_max` to allow the "infallible" construction of ordinary minimum and maximum `NonZero*` instances. The feature is fairly straightforward and already matured for some time in stable toolchains. ```rust let _ = NonZeroU8::MIN; let _ = NonZeroI32::MAX; ``` ## History * On 2022-01-25, implementation was [created](https://github.com/rust-lang/rust/pull/93293). ## Considerations * This report is fruit of the inanition observed after two unsuccessful attempts at getting feedback. * Other constant variants discussed at https://github.com/rust-lang/rust/issues/89065#issuecomment-923238190 are orthogonal to this feature. Fixes https://github.com/rust-lang/rust/issues/89065
This commit is contained in:
commit
ffc0b8a545
@ -1147,12 +1147,10 @@ macro_rules! nonzero_min_max_unsigned {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(nonzero_min_max)]
|
||||
///
|
||||
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), 1", stringify!($Int), ");")]
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_min_max", issue = "89065")]
|
||||
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MIN: Self = Self::new(1).unwrap();
|
||||
|
||||
/// The largest value that can be represented by this non-zero
|
||||
@ -1162,12 +1160,10 @@ macro_rules! nonzero_min_max_unsigned {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(nonzero_min_max)]
|
||||
///
|
||||
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_min_max", issue = "89065")]
|
||||
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
|
||||
}
|
||||
)+
|
||||
@ -1189,12 +1185,10 @@ macro_rules! nonzero_min_max_signed {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(nonzero_min_max)]
|
||||
///
|
||||
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), ", stringify!($Int), "::MIN);")]
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_min_max", issue = "89065")]
|
||||
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MIN: Self = Self::new(<$Int>::MIN).unwrap();
|
||||
|
||||
/// The largest value that can be represented by this non-zero
|
||||
@ -1208,12 +1202,10 @@ macro_rules! nonzero_min_max_signed {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(nonzero_min_max)]
|
||||
///
|
||||
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_min_max", issue = "89065")]
|
||||
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
|
||||
}
|
||||
)+
|
||||
|
Loading…
Reference in New Issue
Block a user