bitflags generates flags enums with well-defined semantics and ergonomic end-user APIs.
You can use
- provide more user-friendly bindings to C APIs where flags may or may not be fully known in advance.
- generate efficient options types with string parsing and formatting support.
You can't use
guarantee only bits corresponding to defined flags will ever be set.
bitflagsallows access to the underlying bits type so arbitrary bits may be set.
bitflagsonly generates types where set bits denote the presence of some combination of flags.
Add this to your
and this to your source code:
Generate a flags structure:
// The `bitflags!` macro generates `struct`s that manage a set of flags.
Rust Version Support
The minimum supported Rust version is documented in the
This may be bumped in minor releases as necessary.