Derive Macro bytemuck::CheckedBitPattern

source ·
#[derive(CheckedBitPattern)]
Expand description

Derive the CheckedBitPattern trait for a struct or enum.

The macro ensures that the type follows all the the safety requirements for the CheckedBitPattern trait and derives the required Bits type definition and is_valid_bit_pattern method for the type automatically.

The following constraints need to be satisfied for the macro to succeed (the rest of the constraints are guaranteed by the CheckedBitPattern subtrait bounds, i.e. are guaranteed by the requirements of the NoUninit trait which CheckedBitPattern is a subtrait of):

If applied to a struct:

  • All fields must implement CheckedBitPattern

If applied to an enum:

  • All requirements already checked by NoUninit, just impls the trait