#Bitflags in Rust
Usage
Cargo.toml
[]
= "*"
= "*"
extern crate enumflags;
extern crate enumflags_derive;
Features
- Uses enums to represent BitFlags.
- Detects incorrect BitFlags at compile time.
- Has a similar API compared to the popular bitflags crate.
- Does not expose the generated types explicity. The user interacts exclusivly with
struct BitFields<Enum>;
. - Prints the binary flag value as well as the flag enums
BitFlags { 0b1111, Flags::[A, B, C, D] }
.
Detects incorrect flags values
Error:
error: custom derive attribute panicked
-/main.rs:6:10
|
6 |
| ^^^^^^^^^
|
= help: message: The following flags are not unique:
Detects flags that are too big
Error:
error: custom derive attribute panicked
-/main.rs:6:10
|
6 |
| ^^^^^^^^^
|
= help: message: Value '0b100000000' is too big for an u8
Detects missing flags
Error:
error: custom derive attribute panicked
-/main.rs:6:10
|
6 |
| ^^^^^^^^^
|
= help: message: At least one variant was not initialized explicity with a value.
extern crate enumflags;
extern crate enumflags_derive;
use *;