When given a #[bitfield] struct with a #[repr = uN], e.g. #[repr = u32] attribute the #[bitfield] macro shall make sure that the generated bitfield struct respects the bitwidth of the uN, e.g. 8 bits for u8, 16 bits for u16, etc.
Also it shall generate From<uN> and From<BitfieldStruct> for uN implementations.
Obviously having #[repr(uN)] also changes the underlying representation of the bitfield type to uN.
When given a
#[bitfield]
struct with a#[repr = uN]
, e.g.#[repr = u32]
attribute the#[bitfield]
macro shall make sure that the generated bitfield struct respects the bitwidth of theuN
, e.g. 8 bits foru8
, 16 bits foru16
, etc.Also it shall generate
From<uN>
andFrom<BitfieldStruct> for uN
implementations. Obviously having#[repr(uN)]
also changes the underlying representation of the bitfield type touN
.Example
This allows the user to only conditionally have the
repr(u32)
effects taken place usingcfg_attr
: