Function faithe::terminated_array
source · [−]pub unsafe fn terminated_array<'a, T: PartialEq>(
ptr: *const 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 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 arr: [u8; 4] = [1, 2, 3, 0];
let terminated = unsafe { terminated_array(arr.as_ptr(), &0) };
assert_eq!(terminated, &[1, 2, 3]);