about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-21 11:08:28 +0800
committerkennytm <kennytm@gmail.com>2018-08-21 17:51:54 +0800
commit7896ac3e08c7ff4c0943dc1ff48dbb9e9c316992 (patch)
tree41b62996c65f81c7626b3988cfe25c0a181aeec3
parent445718084f481956382f65f2020418f6ebeabcde (diff)
parent687cc989ca85f61f6244cabd281d91af2958bdf6 (diff)
downloadrust-7896ac3e08c7ff4c0943dc1ff48dbb9e9c316992.tar.gz
rust-7896ac3e08c7ff4c0943dc1ff48dbb9e9c316992.zip
Rollup merge of #53363 - llogiq:num-individual-nonzero-docs, r=steveklabnik
add individual docs to `core::num::NonZero*`
-rw-r--r--src/libcore/num/mod.rs43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 37856dc5469..b93428c6321 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -34,22 +34,32 @@ macro_rules! impl_nonzero_fmt {
     }
 }
 
+macro_rules! doc_comment {
+    ($x:expr, $($tt:tt)*) => {
+        #[doc = $x]
+        $($tt)*
+    };
+}
+
 macro_rules! nonzero_integers {
     ( $( $Ty: ident($Int: ty); )+ ) => {
         $(
-            /// An integer that is known not to equal zero.
-            ///
-            /// This enables some memory layout optimization.
-            /// For example, `Option<NonZeroU32>` is the same size as `u32`:
-            ///
-            /// ```rust
-            /// use std::mem::size_of;
-            /// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
-            /// ```
-            #[stable(feature = "nonzero", since = "1.28.0")]
-            #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
-            #[repr(transparent)]
-            pub struct $Ty(NonZero<$Int>);
+            doc_comment! {
+                concat!("An integer that is known not to equal zero.
+
+This enables some memory layout optimization.
+For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:
+
+```rust
+use std::mem::size_of;
+assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int),
+">());
+```"),
+                #[stable(feature = "nonzero", since = "1.28.0")]
+                #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
+                #[repr(transparent)]
+                pub struct $Ty(NonZero<$Int>);
+            }
 
             impl $Ty {
                 /// Create a non-zero without checking the value.
@@ -176,13 +186,6 @@ pub mod dec2flt;
 pub mod bignum;
 pub mod diy_float;
 
-macro_rules! doc_comment {
-    ($x:expr, $($tt:tt)*) => {
-        #[doc = $x]
-        $($tt)*
-    };
-}
-
 mod wrapping;
 
 // `Int` + `SignedInt` implemented for signed integers