]> git.lizzy.rs Git - rust.git/commitdiff
Add `BITS` associated constant to all integer types.
authorMara Bos <m-ou.se@m-ou.se>
Tue, 8 Sep 2020 18:17:23 +0000 (20:17 +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 050c187e55576b5009becf286bd3c3576b780322..33bcf93676b2a4b852f1f543d8d4946a0a5d4de5 100644 (file)
@@ -348,6 +348,10 @@ 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!("Converts a string slice in a given base to an integer.
 
@@ -2601,6 +2605,10 @@ 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!("Converts a string slice in a given base to an integer.