Function bitfrob::u16_get_region

source ·
pub const fn u16_get_region(low: u32, high: u32, u: u16) -> u16
Expand description

Get the low to high bit region of u.

The low and high values form an inclusive bit range.

Panics

  • low and high can’t exceed the number of bits in the type.
  • low must be less than high.
assert_eq!(u16_get_region(0, 2, u16::MAX), 0b0000_0111_u16);
assert_eq!(u16_get_region(1, 3, u16::MAX), 0b0000_1110_u16);
assert_eq!(u16_get_region(4, 7, u16::MAX), 0b1111_0000_u16);