Function genmask_u8

Source
pub const fn genmask_u8(range: RangeInclusive<u32>) -> u8
Expand description

Creates a compile-time contiguous bitmask for the given range by performing a compile-time assertion that the range is valid.

This version is the default and should be used if the range is known at compile time.

ยงExamples

assert_eq!(genmask_u8(6..=7), 0xc0);
assert_eq!(genmask_u8(0..=0), 0b1);
assert_eq!(genmask_u8(0..=7), u8::MAX);