improve readability of is_power_of_two
This commit is contained in:
parent
a12788a0d7
commit
d689c709ea
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue