Trait quantette::ZeroedIsZero
source · 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§
sourcefn box_zeroed() -> Box<Self>
fn box_zeroed() -> Box<Self>
Allocates the “zero value” of the type directly on the heap by zeroing memory.
Object Safety§
This trait is not object safe.