nybbles

Function get_byte_unchecked

Source
pub unsafe fn get_byte_unchecked(nibbles: &[u8], i: usize) -> u8
Expand description

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

§Safety

i..i + 1 must be in range.

§Examples

let nibbles: &[u8] = &[0x0A, 0x0B, 0x0C, 0x0D];
// SAFETY: in range.
unsafe {
    assert_eq!(get_byte_unchecked(nibbles, 0), 0xAB);
    assert_eq!(get_byte_unchecked(nibbles, 1), 0xBC);
    assert_eq!(get_byte_unchecked(nibbles, 2), 0xCD);
}