Function try_zeroed_slice_box
pub fn try_zeroed_slice_box<T>(length: usize) -> Result<Box<[T]>, ()> ⓘwhere
T: Zeroable,
Available on crate feature
dep_bytemuck
only.Expand description
Allocates a Box<[T]>
with all contents being zeroed out.
This uses the global allocator to create a zeroed allocation and then turns it into a Box. In other words, it’s 100% assured that the zeroed data won’t be put temporarily on the stack. You can make a box of any size without fear of a stack overflow.
§Failure
This fails if the allocation fails, or if a layout cannot be calculated for the allocation.