Rollup merge of #85177 - tspiteri:wrapping-bits, r=joshtriplett

add BITS associated constant to core::num::Wrapping

This keeps `Wrapping` synchronized with the primitives it wraps as for the #32463 `wrapping_int_impl` feature.
This commit is contained in:
Guillaume Gomez 2021-05-13 15:54:13 +02:00 committed by GitHub
commit 16c825485f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -433,6 +433,21 @@ macro_rules! wrapping_int_impl {
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const MAX: Self = Self(<$t>::MAX);
/// Returns the size of this integer type in bits.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(wrapping_int_impl)]
/// use std::num::Wrapping;
///
#[doc = concat!("assert_eq!(<Wrapping<", stringify!($t), ">>::BITS, ", stringify!($t), "::BITS);")]
/// ```
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const BITS: u32 = <$t>::BITS;
/// Returns the number of ones in the binary representation of `self`.
///
/// # Examples