-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Because the BitFlags type comes from the enumflags2 crate, we can not add our own impl blocks for it or impl traits for it.
Would you be interested in an additional macro that allows you to define your own BitFlags type for a specific BitFlag enum?
#[bitflags]
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq)]
enum Flags {
A = 0b0001,
B = 0b0010,
C, // unspecified variants pick unused bits automatically
D = 0b1000,
}
#[flagset(Flags)]
struct Status;
// Yaay, we can do this:
impl Status {
pub fn priority(&self) -> u8 {
if self.contains(Flags::A) {
1
} else {
2
}
}
}Metadata
Metadata
Assignees
Labels
No labels