From 18e4a57b0709fe3122ef20144d123cfaf879c3a3 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 20 Oct 2019 16:22:23 +0000 Subject: [PATCH] constify is_power_of_two --- src/libcore/num/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 8f4ade377e312..7b0cdd67600e8 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -3757,8 +3757,8 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_power_of_two(self) -> bool { - (self.wrapping_sub(1)) & self == 0 && !(self == 0) + pub const fn is_power_of_two(self) -> bool { + (self.wrapping_sub(1) & self == 0) & (self != 0) } }