Function scratchpad::uninitialized_boxed_slice_for_markers [−][src]
pub unsafe fn uninitialized_boxed_slice_for_markers<T>(
marker_count: usize
) -> Box<[T]> where
T: ByteData,
Returns a boxed slice of uninitialized data large enough for tracking of at least the specified number of allocation markers.
Safety
The contents of the boxed slice are left uninitialized; reading from and writing to the slice contents can trigger undefined behavior if not careful.
It is strongly recommended to only allocate slices of
[MaybeUninit
]-wrapped types if supported by the version of Rust used, as
using slices of non-wrapped types cause undefined behavior. This function
will most likely be updated to enforce this restriction in future major
releases of this crate.
Examples
use scratchpad::uninitialized_boxed_slice_for_markers; use std::mem::MaybeUninit; let buffer = unsafe { uninitialized_boxed_slice_for_markers::<MaybeUninit<usize>>(32) }; assert_eq!(buffer.len(), 32);