const_power_of_two
A crate for working with constant generics that are powers of two.
Usage
Add the following to your Cargo.toml:
[]
= "1"
Then, import the corresponding trait for your argument type, and add it to your
trait or implementation's where bounds:
use PowerOfTwoUsize;
;
// NOTE: This is valid, and no error is emitted.
// NOTE: This will emit an error at compile-time.
The integer type is what implements the trait, as you can see above. It's not
the most common Rust pattern, but it's easy to work with once you've seen it
in action. At compile-time, if ALIGNMENT isn't a power of two, an error will
get emitted.
Documentation
You can view the documentation on docs.rs here.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.