Derive Macro bytemuck::Contiguous

source ·
Expand description

Derive the Contiguous trait for an enum

The macro ensures that the enum follows all the the safety requirements for the Contiguous trait.

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

  • The enum must be #[repr(Int)]
  • The enum must be fieldless
  • The enum discriminants must form a contiguous range


#[derive(Copy, Clone, Contiguous)]
enum Test {
  A = 0,
  B = 1,
  C = 2,