@@ -21,9 +21,9 @@ use ops;
21
21
use str:: FromStr ;
22
22
23
23
macro_rules! impl_nonzero_fmt {
24
- ( # [ $stability : meta ] ( $( $Trait: ident ) ,+ ) for $Ty: ident ) => {
24
+ ( ( $( $Trait: ident ) ,+ ) for $Ty: ident ) => {
25
25
$(
26
- #[ $stability ]
26
+ #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
27
27
impl fmt:: $Trait for $Ty {
28
28
#[ inline]
29
29
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
@@ -35,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
35
35
}
36
36
37
37
macro_rules! nonzero_integers {
38
- ( # [ $stability : meta ] $( $Ty: ident( $Int: ty) ; ) + ) => {
38
+ ( $( $Ty: ident( $Int: ty) ; ) + ) => {
39
39
$(
40
40
/// An integer that is known not to equal zero.
41
41
///
@@ -46,7 +46,7 @@ macro_rules! nonzero_integers {
46
46
/// use std::mem::size_of;
47
47
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
48
48
/// ```
49
- #[ $stability ]
49
+ #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
50
50
#[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
51
51
pub struct $Ty( NonZero <$Int>) ;
52
52
@@ -56,14 +56,14 @@ macro_rules! nonzero_integers {
56
56
/// # Safety
57
57
///
58
58
/// The value must not be zero.
59
- #[ $stability ]
59
+ #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
60
60
#[ inline]
61
61
pub const unsafe fn new_unchecked( n: $Int) -> Self {
62
62
$Ty( NonZero ( n) )
63
63
}
64
64
65
65
/// Create a non-zero if the given value is not zero.
66
- #[ $stability ]
66
+ #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
67
67
#[ inline]
68
68
pub fn new( n: $Int) -> Option <Self > {
69
69
if n != 0 {
@@ -74,7 +74,7 @@ macro_rules! nonzero_integers {
74
74
}
75
75
76
76
/// Returns the value as a primitive type.
77
- #[ $stability ]
77
+ #[ stable ( feature = "nonzero" , since = "1.28.0" ) ]
78
78
#[ inline]
79
79
pub fn get( self ) -> $Int {
80
80
self . 0 . 0
@@ -83,15 +83,13 @@ macro_rules! nonzero_integers {
83
83
}
84
84
85
85
impl_nonzero_fmt! {
86
- #[ $stability]
87
86
( Debug , Display , Binary , Octal , LowerHex , UpperHex ) for $Ty
88
87
}
89
88
) +
90
89
}
91
90
}
92
91
93
92
nonzero_integers ! {
94
- #[ unstable( feature = "nonzero" , issue = "49137" ) ]
95
93
NonZeroU8 ( u8 ) ;
96
94
NonZeroU16 ( u16 ) ;
97
95
NonZeroU32 ( u32 ) ;
0 commit comments