[go: up one dir, main page]

u8_with_region

Function u8_with_region 

Source
pub const fn u8_with_region(low: u32, high: u32, old: u8, replacement: u8) -> u8
Expand description

Replaces the low to high bit region of old.

The low and high values form an inclusive bit range.

Bits in replacement outside of the region have no effect.

§Panics

  • low and high can’t exceed the number of bits in the type.
  • low must be less than high.
assert_eq!(u8_with_region(0, 2, 0b11111111_u8, 0), 0b1111_1000_u8);
assert_eq!(u8_with_region(1, 3, 0b11111111_u8, 0), 0b1111_0001_u8);
assert_eq!(u8_with_region(4, 7, 0b11111111_u8, 0), 0b0000_1111_u8);