Stabilize nonzero_is_power_of_two

Fixes 81106
FCP has finished in the tracking issue
This commit is contained in:
Scott McMurray 2021-11-27 13:13:04 -08:00
parent bbad745a68
commit 23045eb622

View File

@ -915,15 +915,13 @@ macro_rules! nonzero_unsigned_is_power_of_two {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// #![feature(nonzero_is_power_of_two)]
///
#[doc = concat!("let eight = std::num::", stringify!($Ty), "::new(8).unwrap();")] #[doc = concat!("let eight = std::num::", stringify!($Ty), "::new(8).unwrap();")]
/// assert!(eight.is_power_of_two()); /// assert!(eight.is_power_of_two());
#[doc = concat!("let ten = std::num::", stringify!($Ty), "::new(10).unwrap();")] #[doc = concat!("let ten = std::num::", stringify!($Ty), "::new(10).unwrap();")]
/// assert!(!ten.is_power_of_two()); /// assert!(!ten.is_power_of_two());
/// ``` /// ```
#[must_use] #[must_use]
#[unstable(feature = "nonzero_is_power_of_two", issue = "81106")] #[stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
#[inline] #[inline]
pub const fn is_power_of_two(self) -> bool { pub const fn is_power_of_two(self) -> bool {
// LLVM 11 normalizes `unchecked_sub(x, 1) & x == 0` to the implementation seen here. // LLVM 11 normalizes `unchecked_sub(x, 1) & x == 0` to the implementation seen here.