pub unsafe trait Zeroable: Sized {
// Provided method
fn zeroed() -> Self { ... }
}
Expand description
Re-export from bytemuck
crate
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§
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
impl Zeroable for __m128d
impl Zeroable for __m128i
impl Zeroable for __m256
impl Zeroable for __m256d
impl Zeroable for __m256i
impl Zeroable for PhantomPinned
impl<A> Zeroable for (A,)where
A: Zeroable,
impl<A, B> Zeroable for (A, B)
impl<A, B, C> Zeroable for (A, B, C)
impl<A, B, C, D> Zeroable for (A, B, C, D)
impl<A, B, C, D, E> Zeroable for (A, B, C, D, E)
impl<A, B, C, D, E, F> Zeroable for (A, B, C, D, E, F)
impl<A, B, C, D, E, F, G> Zeroable for (A, B, C, D, E, F, G)
impl<A, B, C, D, E, F, G, H> Zeroable for (A, B, C, D, E, F, G, H)
impl<T> Zeroable for Option<T>where
T: ZeroableInOption,
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 Cell<T>where
T: Zeroable,
impl<T> Zeroable for UnsafeCell<T>where
T: Zeroable,
impl<T> Zeroable for Reverse<T>where
T: Zeroable,
impl<T> Zeroable for PhantomData<T>where
T: ?Sized,
impl<T> Zeroable for ManuallyDrop<T>where
T: Zeroable,
impl<T> Zeroable for Wrapping<T>where
T: Zeroable,
impl<T, const N: usize> Zeroable for [T; N]where
T: Zeroable,
Implementors§
impl<T> Zeroable for Gray<T>where
T: Zeroable,
impl<T> Zeroable for Bgr<T>where
T: Zeroable,
impl<T> Zeroable for Rgb<T>where
T: Zeroable,
impl<T, A> Zeroable for GrayAlpha<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T, A> Zeroable for Abgr<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T, A> Zeroable for Argb<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T, A> Zeroable for Bgra<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T, A> Zeroable for Rgba<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.