pub trait PowerOfTwo {
// Required methods
fn is_power_of_two(&self) -> bool;
fn next_power_of_two(self) -> Self;
}
Expand description
Functions related to the power of two.
§Examples
use dashu_base::PowerOfTwo;
let n = 5u32;
assert!(!n.is_power_of_two());
assert_eq!(n.next_power_of_two(), 8);
Required Methods§
Sourcefn is_power_of_two(&self) -> bool
fn is_power_of_two(&self) -> bool
Test if self is a power of two (2^k
)
Sourcefn next_power_of_two(self) -> Self
fn next_power_of_two(self) -> Self
Get the smallest power of two greater than or equal to self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.