bitflags2-derive
bitflags2-derive provides the #[flags] procedural macro used by the bitflags2 crate.
Most users should depend on bitflags2 instead of this crate directly:
[]
= "0.1"
What this crate does
The #[flags] macro accepts an enum declaration and expands it into an integer-backed flag type. Variant-level #[flag] markers are parsed by the macro and are not standalone attributes.
use flags;
assert_eq!;
Supported flag expressions
#[flag(...)] supports:
- integer literals, such as
#[flag(0x04)] - variant names, such as
#[flag(Read)] - bitwise OR expressions, such as
#[flag(Read | Write | Execute)] - parenthesized/grouped expressions
Forward references to later variants are supported.
Development
This crate is split into:
lib.rs— procedural macro entry pointparse.rs— enum parsing and value resolutionmodel.rs— parsed model typescodegen.rs— generated Rust code