Skip to content

Commit 38dde33

Browse files
authored
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](rust-lang/rust#93293). ## Considerations * This report is fruit of the inanition observed after two unsuccessful attempts at getting feedback. * Other constant variants discussed at rust-lang/rust#89065 (comment) are orthogonal to this feature. Fixes rust-lang/rust#89065
2 parents 4d3e3b6 + 44afe76 commit 38dde33

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

core/src/num/nonzero.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,10 @@ macro_rules! nonzero_min_max_unsigned {
11471147
/// # Examples
11481148
///
11491149
/// ```
1150-
/// #![feature(nonzero_min_max)]
1151-
///
11521150
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
11531151
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), 1", stringify!($Int), ");")]
11541152
/// ```
1155-
#[unstable(feature = "nonzero_min_max", issue = "89065")]
1153+
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
11561154
pub const MIN: Self = Self::new(1).unwrap();
11571155

11581156
/// The largest value that can be represented by this non-zero
@@ -1162,12 +1160,10 @@ macro_rules! nonzero_min_max_unsigned {
11621160
/// # Examples
11631161
///
11641162
/// ```
1165-
/// #![feature(nonzero_min_max)]
1166-
///
11671163
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
11681164
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
11691165
/// ```
1170-
#[unstable(feature = "nonzero_min_max", issue = "89065")]
1166+
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
11711167
pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
11721168
}
11731169
)+
@@ -1189,12 +1185,10 @@ macro_rules! nonzero_min_max_signed {
11891185
/// # Examples
11901186
///
11911187
/// ```
1192-
/// #![feature(nonzero_min_max)]
1193-
///
11941188
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
11951189
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), ", stringify!($Int), "::MIN);")]
11961190
/// ```
1197-
#[unstable(feature = "nonzero_min_max", issue = "89065")]
1191+
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
11981192
pub const MIN: Self = Self::new(<$Int>::MIN).unwrap();
11991193

12001194
/// The largest value that can be represented by this non-zero
@@ -1208,12 +1202,10 @@ macro_rules! nonzero_min_max_signed {
12081202
/// # Examples
12091203
///
12101204
/// ```
1211-
/// #![feature(nonzero_min_max)]
1212-
///
12131205
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
12141206
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
12151207
/// ```
1216-
#[unstable(feature = "nonzero_min_max", issue = "89065")]
1208+
#[stable(feature = "nonzero_min_max", since = "CURRENT_RUSTC_VERSION")]
12171209
pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
12181210
}
12191211
)+

0 commit comments

Comments
 (0)