const NIBBLE_SIZE_IN_BITS: u8 = 4;
pub(crate) const fn nibbles_from_byte(byte: u8) -> (u8, u8) {
let left = byte >> NIBBLE_SIZE_IN_BITS;
let right = byte & 0b1111;
(left, right)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_nibbles_from_byte() {
assert_eq!(nibbles_from_byte(0b1111_1111), (0b1111, 0b1111));
assert_eq!(nibbles_from_byte(0b0000_0000), (0b0000, 0b0000));
assert_eq!(nibbles_from_byte(0b0000_1111), (0b0000, 0b1111));
assert_eq!(nibbles_from_byte(0b1111_0000), (0b1111, 0b0000));
assert_eq!(nibbles_from_byte(0b1010_1010), (0b1010, 0b1010));
assert_eq!(nibbles_from_byte(0b0101_0101), (0b0101, 0b0101));
assert_eq!(nibbles_from_byte(0b1001_1001), (0b1001, 0b1001));
}
}