bytemuck::allocation

Function try_zeroed_box

Source
pub fn try_zeroed_box<T: Zeroable>() -> Result<Box<T>, ()>
Expand description

Allocates a Box<T> with all of the 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.