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 impl
s are feature gated due to the MSRV policy:
MaybeUninit<T>
was not available in 1.34.0, but is available under thezeroable_maybe_uninit
feature flag.Atomic*
types require Rust 1.60.0 or later to work on certain platforms, but is available under thezeroable_atomics
feature flag.[T; N]
for arbitraryN
requires themin_const_generics
feature flag.
Provided Methods§
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
impl Zeroable for bool
impl Zeroable for char
impl Zeroable for f32
impl Zeroable for f64
impl Zeroable for i8
impl Zeroable for i16
impl Zeroable for i32
impl Zeroable for i64
impl Zeroable for i128
impl Zeroable for isize
impl Zeroable for *const str
impl Zeroable for *mut str
impl Zeroable for u8
impl Zeroable for u16
impl Zeroable for u32
impl Zeroable for u64
impl Zeroable for u128
impl Zeroable for ()
impl Zeroable for usize
impl Zeroable for __m128
Available on x86-64 only.
impl Zeroable for __m128d
Available on x86-64 only.
impl Zeroable for __m128i
Available on x86-64 only.
impl Zeroable for __m256
Available on x86-64 only.
impl Zeroable for __m256d
Available on x86-64 only.
impl Zeroable for __m256i
Available on x86-64 only.
impl Zeroable for PhantomPinned
impl Zeroable for AtomicBool
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicI8
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicI16
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicI32
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicI64
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicIsize
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicU8
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicU16
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicU32
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicU64
Available on crate feature
zeroable_atomics
only.impl Zeroable for AtomicUsize
Available on crate feature
zeroable_atomics
only.impl<A: Zeroable> Zeroable for (A,)
impl<A: Zeroable, B: Zeroable> Zeroable for (A, B)
impl<A: Zeroable, B: Zeroable, C: Zeroable> Zeroable for (A, B, C)
impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable> Zeroable for (A, B, C, D)
impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable> Zeroable for (A, B, C, D, E)
impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable, F: Zeroable> Zeroable for (A, B, C, D, E, F)
impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable, F: Zeroable, G: Zeroable> Zeroable for (A, B, C, D, E, F, G)
impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable, F: Zeroable, G: Zeroable, H: Zeroable> Zeroable for (A, B, C, D, E, F, G, H)
impl<T> Zeroable for *const [T]
impl<T> Zeroable for *const T
impl<T> Zeroable for *mut [T]
impl<T> Zeroable for *mut T
impl<T> Zeroable for AtomicPtr<T>
Available on crate feature
zeroable_atomics
only.impl<T> Zeroable for MaybeUninit<T>
Available on crate feature
zeroable_maybe_uninit
only.impl<T, const N: usize> Zeroable for [T; N]where
T: Zeroable,
Available on crate feature
min_const_generics
only.