@@ -119,6 +119,34 @@ macro_rules! int_impl {
119119 $add_with_overflow: path,
120120 $sub_with_overflow: path,
121121 $mul_with_overflow: path) => {
122+
123+ // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
124+ // calling the `mem::size_of` function.
125+ #[ unstable( feature = "num_bits_bytes" ,
126+ reason = "may want to be an associated function" ,
127+ issue = "27753" ) ]
128+ #[ allow( missing_docs) ]
129+ pub const BITS : usize = $BITS;
130+ // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
131+ // calling the `mem::size_of` function.
132+ #[ unstable( feature = "num_bits_bytes" ,
133+ reason = "may want to be an associated function" ,
134+ issue = "27753" ) ]
135+ #[ allow( missing_docs) ]
136+ pub const BYTES : usize = ( $BITS / 8 ) ;
137+
138+ // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
139+ // calling the `Bounded::min_value` function.
140+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
141+ #[ allow( missing_docs) ]
142+ pub const MIN : $ActualT = ( -1 as $ActualT) << ( $BITS - 1 ) ;
143+ // FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
144+ // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
145+ // calling the `Bounded::max_value` function.
146+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
147+ #[ allow( missing_docs) ]
148+ pub const MAX : $ActualT = !<$ActualT>:: MIN ;
149+
122150 /// Returns the smallest value that can be represented by this integer type.
123151 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
124152 #[ inline]
@@ -669,6 +697,25 @@ macro_rules! uint_impl {
669697 $add_with_overflow: path,
670698 $sub_with_overflow: path,
671699 $mul_with_overflow: path) => {
700+
701+ #[ unstable( feature = "num_bits_bytes" ,
702+ reason = "may want to be an associated function" ,
703+ issue = "27753" ) ]
704+ #[ allow( missing_docs) ]
705+ pub const BITS : usize = $BITS;
706+ #[ unstable( feature = "num_bits_bytes" ,
707+ reason = "may want to be an associated function" ,
708+ issue = "27753" ) ]
709+ #[ allow( missing_docs) ]
710+ pub const BYTES : usize = ( $BITS / 8 ) ;
711+
712+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
713+ #[ allow( missing_docs) ]
714+ pub const MIN : $ActualT = 0 as $ActualT;
715+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
716+ #[ allow( missing_docs) ]
717+ pub const MAX : $ActualT = !0 as $ActualT;
718+
672719 /// Returns the smallest value that can be represented by this integer type.
673720 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
674721 #[ inline]
0 commit comments