]> git.lizzy.rs Git - rust.git/commitdiff
Add example/test to <int types>::BITS.
authorMara Bos <m-ou.se@m-ou.se>
Tue, 8 Sep 2020 18:24:55 +0000 (20:24 +0200)
committerMara Bos <m-ou.se@m-ou.se>
Sat, 19 Sep 2020 04:50:45 +0000 (06:50 +0200)
library/core/src/num/mod.rs

index 33bcf93676b2a4b852f1f543d8d4946a0a5d4de5..5df67a5f53df74628035da642cfbbc38bcb1f629 100644 (file)
@@ -348,9 +348,19 @@ macro_rules! int_impl {
             pub const MAX: Self = !Self::MIN;
         }
 
-        /// The size of this integer type in bits.
-        #[unstable(feature = "int_bits_const", issue = "none")]
-        pub const BITS: u32 = $BITS;
+        doc_comment! {
+            concat!("The size of this integer type in bits.
+
+# Examples
+
+```
+", $Feature, "#![feature(int_bits_const)]
+assert_eq!(", stringify!($SelfT), "::BITS, ", stringify!($BITS), ");",
+$EndFeature, "
+```"),
+            #[unstable(feature = "int_bits_const", issue = "none")]
+            pub const BITS: u32 = $BITS;
+        }
 
         doc_comment! {
             concat!("Converts a string slice in a given base to an integer.
@@ -2605,9 +2615,19 @@ macro_rules! uint_impl {
             pub const MAX: Self = !0;
         }
 
-        /// The size of this integer type in bits.
-        #[unstable(feature = "int_bits_const", issue = "none")]
-        pub const BITS: u32 = $BITS;
+        doc_comment! {
+            concat!("The size of this integer type in bits.
+
+# Examples
+
+```
+", $Feature, "#![feature(int_bits_const)]
+assert_eq!(", stringify!($SelfT), "::BITS, ", stringify!($BITS), ");",
+$EndFeature, "
+```"),
+            #[unstable(feature = "int_bits_const", issue = "none")]
+            pub const BITS: u32 = $BITS;
+        }
 
         doc_comment! {
             concat!("Converts a string slice in a given base to an integer.