Derive Macro bytemuck_derive::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:
If applied to a struct:
- All fields must implement
CheckedBitPattern
- The struct must be
#[repr(C)]
or#[repr(transparent)]
- The struct must contain no generic parameters
If applied to an enum:
- The enum must be explicit
#[repr(Int)]
- All fields in variants must implement
CheckedBitPattern
- The enum must contain no generic parameters