@@ -10,9 +10,9 @@ use ops;
1010use str:: FromStr ;
1111
1212macro_rules! impl_nonzero_fmt {
13- ( ( $( $Trait: ident ) ,+ ) for $Ty: ident ) => {
13+ ( # [ $stability : meta ] ( $( $Trait: ident ) ,+ ) for $Ty: ident ) => {
1414 $(
15- #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
15+ #[ $stability ]
1616 impl fmt:: $Trait for $Ty {
1717 #[ inline]
1818 fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
@@ -31,7 +31,7 @@ macro_rules! doc_comment {
3131}
3232
3333macro_rules! nonzero_integers {
34- ( $( $Ty: ident( $Int: ty) ; ) + ) => {
34+ ( $( # [ $stability : meta ] $Ty: ident( $Int: ty) ; ) + ) => {
3535 $(
3636 doc_comment! {
3737 concat!( "An integer that is known not to equal zero.
@@ -41,10 +41,10 @@ For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!(
4141
4242```rust
4343use std::mem::size_of;
44- assert_eq!(size_of::<Option<std ::num::" , stringify!( $Ty) , ">>(), size_of::<" , stringify!( $Int) ,
44+ assert_eq!(size_of::<Option<core ::num::" , stringify!( $Ty) , ">>(), size_of::<" , stringify!( $Int) ,
4545">());
4646```" ) ,
47- #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
47+ #[ $stability ]
4848 #[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
4949 #[ repr( transparent) ]
5050 #[ rustc_layout_scalar_valid_range_start( 1 ) ]
@@ -57,14 +57,14 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st
5757 /// # Safety
5858 ///
5959 /// The value must not be zero.
60- #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
60+ #[ $stability ]
6161 #[ inline]
6262 pub const unsafe fn new_unchecked( n: $Int) -> Self {
6363 $Ty( n)
6464 }
6565
6666 /// Create a non-zero if the given value is not zero.
67- #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
67+ #[ $stability ]
6868 #[ inline]
6969 pub fn new( n: $Int) -> Option <Self > {
7070 if n != 0 {
@@ -75,7 +75,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st
7575 }
7676
7777 /// Returns the value as a primitive type.
78- #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
78+ #[ $stability ]
7979 #[ inline]
8080 pub const fn get( self ) -> $Int {
8181 self . 0
@@ -91,19 +91,25 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st
9191 }
9292
9393 impl_nonzero_fmt! {
94- ( Debug , Display , Binary , Octal , LowerHex , UpperHex ) for $Ty
94+ # [ $stability ] ( Debug , Display , Binary , Octal , LowerHex , UpperHex ) for $Ty
9595 }
9696 ) +
9797 }
9898}
9999
100100nonzero_integers ! {
101- NonZeroU8 ( u8 ) ;
102- NonZeroU16 ( u16 ) ;
103- NonZeroU32 ( u32 ) ;
104- NonZeroU64 ( u64 ) ;
105- NonZeroU128 ( u128 ) ;
106- NonZeroUsize ( usize ) ;
101+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU8 ( u8 ) ;
102+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU16 ( u16 ) ;
103+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU32 ( u32 ) ;
104+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU64 ( u64 ) ;
105+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroU128 ( u128 ) ;
106+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ] NonZeroUsize ( usize ) ;
107+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI8 ( i8 ) ;
108+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI16 ( i16 ) ;
109+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI32 ( i32 ) ;
110+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI64 ( i64 ) ;
111+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroI128 ( i128 ) ;
112+ #[ stable( feature = "signed_nonzero" , since = "1.34.0" ) ] NonZeroIsize ( isize ) ;
107113}
108114
109115/// Provides intentionally-wrapped arithmetic on `T`.
0 commit comments