Skip to content

Commit

Permalink
Rollup merge of rust-lang#85177 - tspiteri:wrapping-bits, r=joshtriplett
Browse files Browse the repository at this point in the history
add BITS associated constant to core::num::Wrapping

This keeps `Wrapping` synchronized with the primitives it wraps as for the rust-lang#32463 `wrapping_int_impl` feature.
  • Loading branch information
GuillaumeGomez authored May 13, 2021
2 parents 5aa40dd + a381e29 commit 16c8254
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions library/core/src/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 16c8254

Please sign in to comment.