@@ -515,12 +515,37 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
515
515
516
516
#[ rustfmt:: skip] // https://github.com/rust-lang/rustfmt/issues/5974
517
517
macro_rules! nonzero_integer_signedness_dependent_methods {
518
- // Methods for unsigned nonzero types only.
518
+ // Associated items for unsigned nonzero types only.
519
519
(
520
520
Self = $Ty: ident,
521
521
Primitive = unsigned $Int: ident,
522
522
UnsignedPrimitive = $Uint: ty,
523
523
) => {
524
+ /// The smallest value that can be represented by this non-zero
525
+ /// integer type, 1.
526
+ ///
527
+ /// # Examples
528
+ ///
529
+ /// ```
530
+ #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
531
+ #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MIN.get(), 1" , stringify!( $Int) , ");" ) ]
532
+ /// ```
533
+ #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
534
+ pub const MIN : Self = Self :: new( 1 ) . unwrap( ) ;
535
+
536
+ /// The largest value that can be represented by this non-zero
537
+ /// integer type,
538
+ #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MAX`]." ) ]
539
+ ///
540
+ /// # Examples
541
+ ///
542
+ /// ```
543
+ #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
544
+ #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MAX.get(), " , stringify!( $Int) , "::MAX);" ) ]
545
+ /// ```
546
+ #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
547
+ pub const MAX : Self = Self :: new( <$Int>:: MAX ) . unwrap( ) ;
548
+
524
549
/// Adds an unsigned integer to a non-zero value.
525
550
/// Checks for overflow and returns [`None`] on overflow.
526
551
/// As a consequence, the result cannot wrap to zero.
@@ -1177,39 +1202,6 @@ macro_rules! sign_dependent_expr {
1177
1202
} ;
1178
1203
}
1179
1204
1180
- macro_rules! nonzero_min_max_unsigned {
1181
- ( $( $Ty: ident( $Int: ident) ; ) + ) => {
1182
- $(
1183
- impl $Ty {
1184
- /// The smallest value that can be represented by this non-zero
1185
- /// integer type, 1.
1186
- ///
1187
- /// # Examples
1188
- ///
1189
- /// ```
1190
- #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
1191
- #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MIN.get(), 1" , stringify!( $Int) , ");" ) ]
1192
- /// ```
1193
- #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
1194
- pub const MIN : Self = Self :: new( 1 ) . unwrap( ) ;
1195
-
1196
- /// The largest value that can be represented by this non-zero
1197
- /// integer type,
1198
- #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MAX`]." ) ]
1199
- ///
1200
- /// # Examples
1201
- ///
1202
- /// ```
1203
- #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
1204
- #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MAX.get(), " , stringify!( $Int) , "::MAX);" ) ]
1205
- /// ```
1206
- #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
1207
- pub const MAX : Self = Self :: new( <$Int>:: MAX ) . unwrap( ) ;
1208
- }
1209
- ) +
1210
- }
1211
- }
1212
-
1213
1205
macro_rules! nonzero_min_max_signed {
1214
1206
( $( $Ty: ident( $Int: ident) ; ) + ) => {
1215
1207
$(
@@ -1252,15 +1244,6 @@ macro_rules! nonzero_min_max_signed {
1252
1244
}
1253
1245
}
1254
1246
1255
- nonzero_min_max_unsigned ! {
1256
- NonZeroU8 ( u8 ) ;
1257
- NonZeroU16 ( u16 ) ;
1258
- NonZeroU32 ( u32 ) ;
1259
- NonZeroU64 ( u64 ) ;
1260
- NonZeroU128 ( u128 ) ;
1261
- NonZeroUsize ( usize ) ;
1262
- }
1263
-
1264
1247
nonzero_min_max_signed ! {
1265
1248
NonZeroI8 ( i8 ) ;
1266
1249
NonZeroI16 ( i16 ) ;
0 commit comments