Generate bit-flags struct and methods.
It's very simple and easy to use. See the example below for details.
Usage
Import this crate and paste
to your Cargo.toml
:
[]
= "0.1"
= "1.0"
Invoke the tiny_bit_flags!
macro to define flags:
!
tiny_bit_flags
This actually generates the following code:
// struct
;
Then you can use them in your program:
let mut f = PrimFlags; // initialize
assert!; // check flag
assert!;
f.clear_writable; // clear flag
assert!;
f.set_executable; // set flag
assert!;
You can use pub
before struct
to make all above to be public:
tiny_bit_flags! {
+ pub struct PrimFlags: u32 {
- struct PrimFlags: u32 {
You can also derive some traits on the struct:
tiny_bit_flags! {
+ #[derive(Copy, Clone, Debug, Default)]
struct PrimFlags: u32 {