pub trait IsPowerOfTwo: Sized {
// Required method
fn is_power_of_two(self) -> bool;
}Expand description
Power-of-two predicate, for unsigned integers.
Required Methods§
Sourcefn is_power_of_two(self) -> bool
fn is_power_of_two(self) -> bool
Returns true if and only if self == 2^k for some integer k.
Zero is not a power of two.
use const_num_traits::IsPowerOfTwo;
assert!(IsPowerOfTwo::is_power_of_two(16u8));
assert!(!IsPowerOfTwo::is_power_of_two(10u8));
assert!(!IsPowerOfTwo::is_power_of_two(0u8));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".