pub unsafe fn terminated_array_mut<'a, T: PartialEq>(
    ptr: *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 array by finding it’s last element. Returns a slice NOT INCLUDING the last element. Maximum length is usize::MAX

Safety

ptr must be valid, properly alligned.

let mut arr: [u8; 4] = [1, 2, 3, 0];
let terminated = unsafe { terminated_array_mut(arr.as_mut_ptr(), &0) };
assert_eq!(terminated, &[1, 2, 3]);
terminated[1] = 5;
assert_eq!(arr, [1, 5, 3, 0]);