diff options
| author | Trevor Spiteri <tspiteri@ieee.org> | 2019-10-21 15:35:54 +0200 |
|---|---|---|
| committer | Trevor Spiteri <tspiteri@ieee.org> | 2019-10-21 15:35:54 +0200 |
| commit | d689c709ea6e942de1687d918eaee541610aa86d (patch) | |
| tree | 07edc0b08943870e5ae83847acb7193f93acacbd /src/libcore/num | |
| parent | a12788a0d77f1ad906bc1d51c4684dd8723278e0 (diff) | |
| download | rust-d689c709ea6e942de1687d918eaee541610aa86d.tar.gz rust-d689c709ea6e942de1687d918eaee541610aa86d.zip | |
improve readability of is_power_of_two
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 82c1943b7d0..e14c886aec3 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -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 } } |
