Crate const_power_of_two

Crate const_power_of_two 

Source
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§

PowerOfTwoU8
A marker trait for u8 values that are a power of two.
PowerOfTwoU16
A marker trait for u16 values that are a power of two.
PowerOfTwoU32
A marker trait for u32 values that are a power of two.
PowerOfTwoU64
A marker trait for u64 values that are a power of two.
PowerOfTwoU128
A marker trait for u128 values that are a power of two.
PowerOfTwoUsize
A marker trait for usize values that are a power of two.