@@ -791,13 +791,47 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
791
791
}
792
792
} ;
793
793
794
- // Methods for signed nonzero types only.
794
+ // Associated items for signed nonzero types only.
795
795
(
796
796
Self = $Ty: ident,
797
797
Primitive = signed $Int: ident,
798
798
UnsignedNonZero = $Uty: ident,
799
799
UnsignedPrimitive = $Uint: ty,
800
800
) => {
801
+ /// The smallest value that can be represented by this non-zero
802
+ /// integer type,
803
+ #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MIN`]." ) ]
804
+ ///
805
+ /// Note: While most integer types are defined for every whole
806
+ /// number between `MIN` and `MAX`, signed non-zero integers are
807
+ /// a special case. They have a "gap" at 0.
808
+ ///
809
+ /// # Examples
810
+ ///
811
+ /// ```
812
+ #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
813
+ #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MIN.get(), " , stringify!( $Int) , "::MIN);" ) ]
814
+ /// ```
815
+ #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
816
+ pub const MIN : Self = Self :: new( <$Int>:: MIN ) . unwrap( ) ;
817
+
818
+ /// The largest value that can be represented by this non-zero
819
+ /// integer type,
820
+ #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MAX`]." ) ]
821
+ ///
822
+ /// Note: While most integer types are defined for every whole
823
+ /// number between `MIN` and `MAX`, signed non-zero integers are
824
+ /// a special case. They have a "gap" at 0.
825
+ ///
826
+ /// # Examples
827
+ ///
828
+ /// ```
829
+ #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
830
+ #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MAX.get(), " , stringify!( $Int) , "::MAX);" ) ]
831
+ /// ```
832
+ #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
833
+ pub const MAX : Self = Self :: new( <$Int>:: MAX ) . unwrap( ) ;
834
+
801
835
/// Computes the absolute value of self.
802
836
#[ doc = concat!( "See [`" , stringify!( $Int) , "::abs`]" ) ]
803
837
/// for documentation on overflow behaviour.
@@ -1188,57 +1222,6 @@ macro_rules! sign_dependent_expr {
1188
1222
} ;
1189
1223
}
1190
1224
1191
- macro_rules! nonzero_min_max_signed {
1192
- ( $( $Ty: ident( $Int: ident) ; ) + ) => {
1193
- $(
1194
- impl $Ty {
1195
- /// The smallest value that can be represented by this non-zero
1196
- /// integer type,
1197
- #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MIN`]." ) ]
1198
- ///
1199
- /// Note: While most integer types are defined for every whole
1200
- /// number between `MIN` and `MAX`, signed non-zero integers are
1201
- /// a special case. They have a "gap" at 0.
1202
- ///
1203
- /// # Examples
1204
- ///
1205
- /// ```
1206
- #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
1207
- #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MIN.get(), " , stringify!( $Int) , "::MIN);" ) ]
1208
- /// ```
1209
- #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
1210
- pub const MIN : Self = Self :: new( <$Int>:: MIN ) . unwrap( ) ;
1211
-
1212
- /// The largest value that can be represented by this non-zero
1213
- /// integer type,
1214
- #[ doc = concat!( "equal to [`" , stringify!( $Int) , "::MAX`]." ) ]
1215
- ///
1216
- /// Note: While most integer types are defined for every whole
1217
- /// number between `MIN` and `MAX`, signed non-zero integers are
1218
- /// a special case. They have a "gap" at 0.
1219
- ///
1220
- /// # Examples
1221
- ///
1222
- /// ```
1223
- #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
1224
- #[ doc = concat!( "assert_eq!(" , stringify!( $Ty) , "::MAX.get(), " , stringify!( $Int) , "::MAX);" ) ]
1225
- /// ```
1226
- #[ stable( feature = "nonzero_min_max" , since = "1.70.0" ) ]
1227
- pub const MAX : Self = Self :: new( <$Int>:: MAX ) . unwrap( ) ;
1228
- }
1229
- ) +
1230
- }
1231
- }
1232
-
1233
- nonzero_min_max_signed ! {
1234
- NonZeroI8 ( i8 ) ;
1235
- NonZeroI16 ( i16 ) ;
1236
- NonZeroI32 ( i32 ) ;
1237
- NonZeroI64 ( i64 ) ;
1238
- NonZeroI128 ( i128 ) ;
1239
- NonZeroIsize ( isize ) ;
1240
- }
1241
-
1242
1225
macro_rules! nonzero_bits {
1243
1226
( $( $Ty: ident( $Int: ty) ; ) + ) => {
1244
1227
$(
0 commit comments