pub fn bit<T: Copy>(index: T) -> Bit<T>
Expand description
Creates a bit mask with a single bit set.
Examples
let mut x = 0xfeu32;
assert_eq!(x & bit(0), 0);
assert_eq!(x & bit(1), 2);
assert_eq!(x & bit(2), 4);
assert_eq!(x & bit(3), 8);
x |= bit(0);
assert_eq!(x, 0xff);
x &= !bit(1);
assert_eq!(x, 0xfd);
x &= !bit(7);
assert_eq!(x, 0x7d);
let y: u64 = bit(34).into();
assert_eq!(y, 0x400000000);
assert_eq!(y | bit(35), 0xc00000000);