pub unsafe trait PointerLength {
fn len(ptr: *const Self) -> usize;
}
#[cfg(feature = "slice_ptr_len")]
unsafe impl<T> PointerLength for [T] {
#[inline]
fn len(ptr: *const Self) -> usize {
<*const [T]>::len(ptr)
}
}
#[cfg(not(feature = "slice_ptr_len"))]
unsafe impl<T> PointerLength for [T] {
#[track_caller]
#[cold]
fn len(_: *const Self) -> usize {
panic!("calling this method on slice pointers requires the `slice_ptr_len` feature to be enabled")
}
}
unsafe impl <T, const N: usize> PointerLength for [T; N] {
#[inline]
fn len(_: *const Self) -> usize {
N
}
}