@@ -34,22 +34,32 @@ macro_rules! impl_nonzero_fmt {
34
34
}
35
35
}
36
36
37
+ macro_rules! doc_comment {
38
+ ( $x: expr, $( $tt: tt) * ) => {
39
+ #[ doc = $x]
40
+ $( $tt) *
41
+ } ;
42
+ }
43
+
37
44
macro_rules! nonzero_integers {
38
45
( $( $Ty: ident( $Int: ty) ; ) + ) => {
39
46
$(
40
- /// An integer that is known not to equal zero.
41
- ///
42
- /// This enables some memory layout optimization.
43
- /// For example, `Option<NonZeroU32>` is the same size as `u32`:
44
- ///
45
- /// ```rust
46
- /// use std::mem::size_of;
47
- /// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
48
- /// ```
49
- #[ stable( feature = "nonzero" , since = "1.28.0" ) ]
50
- #[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
51
- #[ repr( transparent) ]
52
- pub struct $Ty( NonZero <$Int>) ;
47
+ doc_comment! {
48
+ concat!( "An integer that is known not to equal zero.
49
+
50
+ This enables some memory layout optimization.
51
+ For example, `Option<" , stringify!( $Ty) , ">` is the same size as `" , stringify!( $Int) , "`:
52
+
53
+ ```rust
54
+ use std::mem::size_of;
55
+ assert_eq!(size_of::<Option<std::num::" , stringify!( $Ty) , ">>(), size_of::<" , stringify!( $Int) ,
56
+ ">());
57
+ ```" ) ,
58
+ #[ stable( feature = "nonzero" , since = "1.28.0" ) ]
59
+ #[ derive( Copy , Clone , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
60
+ #[ repr( transparent) ]
61
+ pub struct $Ty( NonZero <$Int>) ;
62
+ }
53
63
54
64
impl $Ty {
55
65
/// Create a non-zero without checking the value.
@@ -176,13 +186,6 @@ pub mod dec2flt;
176
186
pub mod bignum;
177
187
pub mod diy_float;
178
188
179
- macro_rules! doc_comment {
180
- ( $x: expr, $( $tt: tt) * ) => {
181
- #[ doc = $x]
182
- $( $tt) *
183
- } ;
184
- }
185
-
186
189
mod wrapping;
187
190
188
191
// `Int` + `SignedInt` implemented for signed integers
0 commit comments