Skip to main content

BitFlag

Derive Macro BitFlag 

Source
#[derive(BitFlag)]
Expand description

Derive alternative to [bitflagset::bitflag!] for #[repr(u8)] enums.

Generates From<Enum> for u8, TryFrom<u8> for Enum, and impl BitFlag. Useful for tools like cbindgen that cannot expand macro_rules! invocations.

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, BitFlag)]
#[repr(u8)]
enum Color {
    Red,
    Green,
    Blue,
}