Derive Macro bytemuck::NoUninit

source ·
#[derive(NoUninit)]
Expand description

Derive the NoUninit trait for a struct or enum

The macro ensures that the type follows all the the safety requirements for the NoUninit trait.

The following constraints need to be satisfied for the macro to succeed (the rest of the constraints are guaranteed by the NoUninit subtrait bounds, i.e. the type must be Sized + Copy + 'static):

If applied to a struct:

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

If applied to an enum:

  • The enum must be explicit #[repr(Int)]
  • All variants must be fieldless
  • The enum must contain no generic parameters