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§

  • A prelude that re-exports all the traits in this crate.

Traits§