Macro pow2::pow2_const

source ·
macro_rules! pow2_const {
    ($value:expr) => { ... };
}
Expand description

A helper macro for defining constant values of Pow2 using constant inputs.

This macro has no way to validate its inputs, unfortunately, due to limitations in const fns and traits. You must pass it a valid power of 2; if the input is not a power of 2, then the results are undefined.

Example

use pow2::{Pow2, pow2_const};
const PAGE_SIZE: Pow2 = pow2_const!(4096);
assert_eq!(PAGE_SIZE.exponent(), 12);