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

Creates a mutable 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 mut arr: [u8; 4] = [1, 2, 3, 0];
let terminated = terminated_slice_mut(&mut arr, &0);
assert_eq!(terminated, &[1, 2, 3]);
terminated[1] = 4;
assert_eq!(terminated, &[1, 4, 3]);