nybbles

Function get_byte

Source
pub fn get_byte(nibbles: &[u8], i: usize) -> Option<u8>
Expand description

Gets the byte at the given index by combining two consecutive nibbles.

ยงExamples

let nibbles: &[u8] = &[0x0A, 0x0B, 0x0C, 0x0D];
assert_eq!(get_byte(nibbles, 0), Some(0xAB));
assert_eq!(get_byte(nibbles, 1), Some(0xBC));
assert_eq!(get_byte(nibbles, 2), Some(0xCD));
assert_eq!(get_byte(nibbles, 3), None);