Function bitfrob::u8_region_mask
source · pub const fn u8_region_mask(low: u32, high: u32) -> u8Expand description
Generates a bit mask where all bits in the region are 1.
The low and high values form an inclusive bit range where the mask
bits are 1.
This is largely a helper function for other functions in this crate, but you can use it yourself if you think it’s useful.
Panics
lowandhighmust be less than the number of bits in the type.lowmust be less than or equal tohigh.
assert_eq!(u8_region_mask(0, 0), 0b0000_0001_u8);
assert_eq!(u8_region_mask(0, 1), 0b0000_0011_u8);
assert_eq!(u8_region_mask(0, 2), 0b0000_0111_u8);
assert_eq!(u8_region_mask(1, 3), 0b0000_1110_u8);
assert_eq!(u8_region_mask(4, 7), 0b1111_0000_u8);
assert_eq!(u8_region_mask(4, 4), 0b0001_0000_u8);