#[bitenum]Expand description
Implements the constant into_bits and from_bits functions for the given enum.
§Parameters
into: Enable/disable theinto_bitsfunction generation.from: Enable/disable thefrom_bitsfunction generation.all: Enable/disable theallfunction generation.
For
into,from, andall, you can either use booleans (#[bitfield(u8, debug = false)]) or cfg attributes (#[bitfield(u8, debug = cfg(test))]) to enable/disable them.
§Examples
use bitfield_struct::bitenum;
#[bitenum(all = false)]
#[repr(u8)]
#[derive(Debug, PartialEq, Eq)]
enum MyEnum {
#[fallback]
A = 0,
B = 1,
C = 2,
}
assert_eq!(MyEnum::from_bits(1), MyEnum::B);
assert_eq!(MyEnum::C.into_bits(), 2);Use the #[fallback] attribute to specify a fallback variant for invalid bit patterns.