improve readability of is_power_of_two
This commit is contained in:
@@ -3750,7 +3750,7 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, "
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub const fn is_power_of_two(self) -> bool {
|
||||
((self.wrapping_sub(1)) & self == 0) & !(self == 0)
|
||||
self.count_ones() == 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user