Constants of type BitFlags cannot be used as a pattern in match expressions because it has manually implemented PartialEq trait.
To be able to use constants of a type in match expressions, the type must derive PartialEq trait.
Here is the exact error message:
to use a constant of type `BitFlags<MyFlag, u16>` in a pattern, `BitFlags<MyFlag, u16>` must be annotated with `#[derive(PartialEq)]`
the traits must be derived, manual `impl`s are not sufficient
see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
But it looks like there is no need in manual implementation of PartialEq trait.
It anyway just compares the inner values
impl<T, N: PartialEq> PartialEq for BitFlags<T, N> {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.val == other.val
}
}
Please consider deriving PartialEq.
Thank you.