Derive Macro bytemuck::Pod

source ·
Expand description

Derive the Pod trait for a struct

The macro ensures that the struct follows all the the safety requirements for the Pod trait.

The following constraints need to be satisfied for the macro to succeed

  • All fields in the struct must implement Pod
  • The struct must be #[repr(C)] or #[repr(transparent)]
  • The struct must not contain any padding bytes
  • The struct contains no generic parameters


#[derive(Copy, Clone, Pod, Zeroable)]
struct Test {
  a: u16,
  b: u16,