Function genmask_u16

Source
pub const fn genmask_u16(range: RangeInclusive<u32>) -> u16
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_u16(6..=15), 0xffc0);
assert_eq!(genmask_u16(0..=0), 0b1);
assert_eq!(genmask_u16(0..=15), u16::MAX);