pub unsafe trait ZeroedIsZero: Sized + Copy {
    // Provided methods
    fn box_zeroed() -> Box<Self> { ... }
    fn fill_zero(&mut self) { ... }
}
Expand description

A marker trait signifying that the “zero value” for the type can be represented by the all zeros bit pattern.

This trait is necessary to be able to allocate large, multi-dimensional, fixed sized arrays directly on the heap. Box::default cannot be used, since Default is only implemented for fixed sized arrays up to length 32. Additionally, while the compiler may allocate fixed sized arrays with a single dimension directly on the heap, it seems to not do the same for multi-dimensional, fixed sized arrays. Without this trait, this could potentially cause a stack overflow.

§Safety

The zero value of the type must be representable by the all zeros bit pattern.

Provided Methods§

source

fn box_zeroed() -> Box<Self>

Allocates the “zero value” of the type directly on the heap by zeroing memory.

source

fn fill_zero(&mut self)

Sets self to the “zero value” by zeroing memory.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ZeroedIsZero for f32

source§

impl ZeroedIsZero for f64

source§

impl ZeroedIsZero for i8

source§

impl ZeroedIsZero for i16

source§

impl ZeroedIsZero for i32

source§

impl ZeroedIsZero for i64

source§

impl ZeroedIsZero for u8

source§

impl ZeroedIsZero for u16

source§

impl ZeroedIsZero for u32

source§

impl ZeroedIsZero for u64

source§

impl<T: ZeroedIsZero, const N: usize> ZeroedIsZero for [T; N]

Implementors§