pub unsafe trait Zeroable: Sized {
// Provided method
fn zeroed() -> Self { ... }
}Expand description
Trait for types that can be safely created with
zeroed.
An all-zeroes value may or may not be the same value as the Default value of the type.
§Safety
- Your type must be inhabited (eg: no Infallible).
- Your type must be allowed to be an “all zeroes” bit pattern (eg: no
NonNull<T>).
§Features
Some impls are feature gated due to the MSRV policy:
MaybeUninit<T>was not available in 1.34.0, but is available under thezeroable_maybe_uninitfeature flag.Atomic*types require Rust 1.60.0 or later to work on certain platforms, but is available under thezeroable_atomicsfeature flag.[T; N]for arbitraryNrequires themin_const_genericsfeature flag.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.