pub const fn non_null_empty_slice(layout: Layout) -> NonNull<[u8]>
Expand description
Creates a dangling NonNull<[u8]>
slice of size 0 with the specified layout alignment.
This function is useful for placeholder or sentinel values where a
NonNull<[u8]>
is required, but no actual memory needs to be allocated.
ยงExamples
use core::alloc::Layout;
use core::ptr::NonNull;
let layout = Layout::from_size_align(16, 8).unwrap();
let empty = non_null_empty_slice(layout);
assert_eq!(empty.len(), 0);