macro_rules! bitflags {
(
$(#[$outer:meta])*
$vis:vis struct $Name:ident : $T:ty {
$(
$(#[$inner:meta])*
const $FLAG:ident = $value:expr;
)*
}
) => { ... };
}Expand description
Defines a bitflags struct with the given flags.
§Example
ⓘ
bitflags! {
/// Documentation for the flags struct
pub struct MyFlags: u32 {
/// First flag
const FLAG_A = 1 << 0;
/// Second flag
const FLAG_B = 1 << 1;
}
}This generates:
- A struct
MyFlags(u32)withCopy,Clone,Debug,Default,PartialEq,Eq,Hash - Associated constants
MyFlags::FLAG_A,MyFlags::FLAG_B, etc. - An
empty()constructor contains(&self, other: Self) -> boolinsert(&mut self, other: Self)remove(&mut self, other: Self)is_empty(&self) -> bool- Bitwise operators:
|,&,^,!,|=,&=,^=