Expand description
§const_power_of_two
This crate provides a set of traits that allow you to work with power-of-two values in a constant generic context.
§Examples
You can use the traits as bounds in constant generic contexts.
use const_power_of_two::PowerOfTwoUsize;
trait MyTrait<const N: usize>
where
usize: PowerOfTwoUsize<N>,
{
// Your code here...
}As you can see in the example above, the integer type is what implements the trait. This was done to make this library rather light and easy to use.
If you use something that is not a power of two, you will get a compile-time error.
Modules§
- prelude
- A prelude that re-exports all the traits in this crate.
Traits§
- Power
OfTwo U8 - A marker trait for
u8values that are a power of two. - Power
OfTwo U16 - A marker trait for
u16values that are a power of two. - Power
OfTwo U32 - A marker trait for
u32values that are a power of two. - Power
OfTwo U64 - A marker trait for
u64values that are a power of two. - Power
OfTwo U128 - A marker trait for
u128values that are a power of two. - Power
OfTwo Usize - A marker trait for
usizevalues that are a power of two.