Trait bytemuck::Zeroable

source ·
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 the zeroable_maybe_uninit feature flag.
  • Atomic* types require Rust 1.60.0 or later to work on certain platforms, but is available under the zeroable_atomics feature flag.
  • [T; N] for arbitrary N requires the min_const_generics feature flag.

Provided Methods§

source

fn zeroed() -> Self

Calls zeroed.

This is a trait method so that you can write MyType::zeroed() in your code. It is a contract of this trait that if you implement it on your type you must not override this method.

Implementations on Foreign Types§

source§

impl Zeroable for bool

source§

impl Zeroable for AtomicU32

source§

impl<T> Zeroable for *const T

source§

impl Zeroable for u64

source§

impl Zeroable for f32

source§

impl Zeroable for AtomicBool

source§

impl Zeroable for __m128d

source§

impl Zeroable for u8

source§

impl Zeroable for u16

source§

impl Zeroable for AtomicI64

source§

impl Zeroable for *const str

source§

impl Zeroable for isize

source§

impl<A: Zeroable, B: Zeroable> Zeroable for (A, B)

source§

impl Zeroable for AtomicI8

source§

impl Zeroable for ()

source§

impl Zeroable for f64

source§

impl<T: Zeroable> Zeroable for ManuallyDrop<T>

source§

impl Zeroable for u128

source§

impl Zeroable for PhantomPinned

source§

impl Zeroable for __m128i

source§

impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable> Zeroable for (A, B, C, D, E)

source§

impl Zeroable for i8

source§

impl<T> Zeroable for *mut [T]

source§

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

source§

impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable, F: Zeroable> Zeroable for (A, B, C, D, E, F)

source§

impl<T: ?Sized> Zeroable for PhantomData<T>

source§

impl Zeroable for AtomicU64

source§

impl<T> Zeroable for AtomicPtr<T>

source§

impl Zeroable for __m256d

source§

impl Zeroable for *mut str

source§

impl Zeroable for AtomicUsize

source§

impl<T> Zeroable for *mut T

source§

impl Zeroable for char

source§

impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable> Zeroable for (A, B, C, D)

source§

impl<A: Zeroable> Zeroable for (A,)

source§

impl Zeroable for usize

source§

impl Zeroable for AtomicIsize

source§

impl<T: ZeroableInOption> Zeroable for Option<T>

source§

impl<T: Zeroable> Zeroable for UnsafeCell<T>

source§

impl Zeroable for AtomicI32

source§

impl Zeroable for u32

source§

impl<A: Zeroable, B: Zeroable, C: Zeroable, D: Zeroable, E: Zeroable, F: Zeroable, G: Zeroable> Zeroable for (A, B, C, D, E, F, G)

source§

impl Zeroable for AtomicU16

source§

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)

source§

impl<A: Zeroable, B: Zeroable, C: Zeroable> Zeroable for (A, B, C)

source§

impl Zeroable for AtomicI16

source§

impl<T: Zeroable> Zeroable for Reverse<T>

source§

impl Zeroable for __m128

source§

impl Zeroable for i32

source§

impl<T: Zeroable> Zeroable for Wrapping<T>

source§

impl Zeroable for __m256i

source§

impl Zeroable for AtomicU8

source§

impl<T: Zeroable> Zeroable for Cell<T>

source§

impl<T> Zeroable for MaybeUninit<T>

source§

impl Zeroable for __m256

source§

impl Zeroable for i128

source§

impl Zeroable for i64

source§

impl Zeroable for i16

source§

impl<T> Zeroable for *const [T]

Implementors§