#[derive(Pod)]Expand description
Derive macro for the Pod trait.
The type is checked for requirements of the Pod trait:
- Must be annotated with
#[repr(C)]or#[repr(transparent)]. - Must have every field’s type implement
Poditself. - Must not have any padding between its fields, define dummy fields to cover the padding.
Note that it is legal for pod types to be a ZST.
§Compile errors
Error reporting is not very ergonomic due to how errors are detected:
-
error[E0277]: the trait bound $TYPE: Pod is not satisfiedThe struct contains a field whose type does not implement
Pod. -
error[E0512]: cannot transmute between types of different sizes, or dependently-sized typesThis error means your struct has padding as its size is not equal to a byte array of length equal to the sum of the size of its fields.
-
error: cannot implement Pod for type $TYPEDeriving
Podis not supported for this type.This includes enums, unions and structs with generics or lifetimes.