mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-24 13:43:04 +00:00
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:
commit
16c825485f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user