bytemuck

Trait 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.

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.

Implementations on Foreign Types§

Source§

impl Zeroable for bool

Source§

impl Zeroable for char

Source§

impl Zeroable for f32

Source§

impl Zeroable for f64

Source§

impl Zeroable for i8

Source§

impl Zeroable for i16

Source§

impl Zeroable for i32

Source§

impl Zeroable for i64

Source§

impl Zeroable for i128

Source§

impl Zeroable for isize

Source§

impl Zeroable for *const str

Source§

impl Zeroable for *mut str

Source§

impl Zeroable for u8

Source§

impl Zeroable for u16

Source§

impl Zeroable for u32

Source§

impl Zeroable for u64

Source§

impl Zeroable for u128

Source§

impl Zeroable for ()

Source§

impl Zeroable for usize

Source§

impl Zeroable for float64x1_t

Source§

impl Zeroable for float64x1x2_t

Source§

impl Zeroable for float64x1x3_t

Source§

impl Zeroable for float64x1x4_t

Source§

impl Zeroable for float64x2_t

Source§

impl Zeroable for float64x2x2_t

Source§

impl Zeroable for float64x2x3_t

Source§

impl Zeroable for float64x2x4_t

Source§

impl Zeroable for float32x2_t

Source§

impl Zeroable for float32x2x2_t

Source§

impl Zeroable for float32x2x3_t

Source§

impl Zeroable for float32x2x4_t

Source§

impl Zeroable for float32x4_t

Source§

impl Zeroable for float32x4x2_t

Source§

impl Zeroable for float32x4x3_t

Source§

impl Zeroable for float32x4x4_t

Source§

impl Zeroable for int8x8_t

Source§

impl Zeroable for int8x8x2_t

Source§

impl Zeroable for int8x8x3_t

Source§

impl Zeroable for int8x8x4_t

Source§

impl Zeroable for int8x16_t

Source§

impl Zeroable for int8x16x2_t

Source§

impl Zeroable for int8x16x3_t

Source§

impl Zeroable for int8x16x4_t

Source§

impl Zeroable for int16x4_t

Source§

impl Zeroable for int16x4x2_t

Source§

impl Zeroable for int16x4x3_t

Source§

impl Zeroable for int16x4x4_t

Source§

impl Zeroable for int16x8_t

Source§

impl Zeroable for int16x8x2_t

Source§

impl Zeroable for int16x8x3_t

Source§

impl Zeroable for int16x8x4_t

Source§

impl Zeroable for int32x2_t

Source§

impl Zeroable for int32x2x2_t

Source§

impl Zeroable for int32x2x3_t

Source§

impl Zeroable for int32x2x4_t

Source§

impl Zeroable for int32x4_t

Source§

impl Zeroable for int32x4x2_t

Source§

impl Zeroable for int32x4x3_t

Source§

impl Zeroable for int32x4x4_t

Source§

impl Zeroable for int64x1_t

Source§

impl Zeroable for int64x1x2_t

Source§

impl Zeroable for int64x1x3_t

Source§

impl Zeroable for int64x1x4_t

Source§

impl Zeroable for int64x2_t

Source§

impl Zeroable for int64x2x2_t

Source§

impl Zeroable for int64x2x3_t

Source§

impl Zeroable for int64x2x4_t

Source§

impl Zeroable for poly8x8_t

Source§

impl Zeroable for poly8x8x2_t

Source§

impl Zeroable for poly8x8x3_t

Source§

impl Zeroable for poly8x8x4_t

Source§

impl Zeroable for poly8x16_t

Source§

impl Zeroable for poly8x16x2_t

Source§

impl Zeroable for poly8x16x3_t

Source§

impl Zeroable for poly8x16x4_t

Source§

impl Zeroable for poly16x4_t

Source§

impl Zeroable for poly16x4x2_t

Source§

impl Zeroable for poly16x4x3_t

Source§

impl Zeroable for poly16x4x4_t

Source§

impl Zeroable for poly16x8_t

Source§

impl Zeroable for poly16x8x2_t

Source§

impl Zeroable for poly16x8x3_t

Source§

impl Zeroable for poly16x8x4_t

Source§

impl Zeroable for poly64x1_t

Source§

impl Zeroable for poly64x1x2_t

Source§

impl Zeroable for poly64x1x3_t

Source§

impl Zeroable for poly64x1x4_t

Source§

impl Zeroable for poly64x2_t

Source§

impl Zeroable for poly64x2x2_t

Source§

impl Zeroable for poly64x2x3_t

Source§

impl Zeroable for poly64x2x4_t

Source§

impl Zeroable for uint8x8_t

Source§

impl Zeroable for uint8x8x2_t

Source§

impl Zeroable for uint8x8x3_t

Source§

impl Zeroable for uint8x8x4_t

Source§

impl Zeroable for uint8x16_t

Source§

impl Zeroable for uint8x16x2_t

Source§

impl Zeroable for uint8x16x3_t

Source§

impl Zeroable for uint8x16x4_t

Source§

impl Zeroable for uint16x4_t

Source§

impl Zeroable for uint16x4x2_t

Source§

impl Zeroable for uint16x4x3_t

Source§

impl Zeroable for uint16x4x4_t

Source§

impl Zeroable for uint16x8_t

Source§

impl Zeroable for uint16x8x2_t

Source§

impl Zeroable for uint16x8x3_t

Source§

impl Zeroable for uint16x8x4_t

Source§

impl Zeroable for uint32x2_t

Source§

impl Zeroable for uint32x2x2_t

Source§

impl Zeroable for uint32x2x3_t

Source§

impl Zeroable for uint32x2x4_t

Source§

impl Zeroable for uint32x4_t

Source§

impl Zeroable for uint32x4x2_t

Source§

impl Zeroable for uint32x4x3_t

Source§

impl Zeroable for uint32x4x4_t

Source§

impl Zeroable for uint64x1_t

Source§

impl Zeroable for uint64x1x2_t

Source§

impl Zeroable for uint64x1x3_t

Source§

impl Zeroable for uint64x1x4_t

Source§

impl Zeroable for uint64x2_t

Source§

impl Zeroable for uint64x2x2_t

Source§

impl Zeroable for uint64x2x3_t

Source§

impl Zeroable for uint64x2x4_t

Source§

impl Zeroable for PhantomPinned

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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<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<T> Zeroable for [T; 0]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 1]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 2]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 3]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 4]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 5]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 6]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 7]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 8]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 9]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 10]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 11]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 12]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 13]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 14]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 15]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 16]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 17]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 18]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 19]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 20]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 21]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 22]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 23]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 24]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 25]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 26]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 27]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 28]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 29]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 30]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 31]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 32]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 48]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 64]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 96]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 128]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 256]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 512]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 1024]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 2048]
where T: Zeroable,

Source§

impl<T> Zeroable for [T; 4096]
where T: Zeroable,

Source§

impl<T> Zeroable for *const [T]

Source§

impl<T> Zeroable for *const T

Source§

impl<T> Zeroable for *mut [T]

Source§

impl<T> Zeroable for *mut T

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§