pub fn terminated_slice<'a, T: PartialEq>(slice: &'a [T], last: T) -> &'a [T]Notable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Expand description

Creates an immutable slice from the terminated slice by finding it’s last element. Returns a slice NOT INCLUDING the last element. Returns an empty slice if failed to find the last element.

Safety

ptr must be valid, properly alligned.

let arr: [u8; 4] = [1, 2, 3, 0];
let terminated = terminated_slice(&arr, &0);
assert_eq!(terminated, &[1, 2, 3]);