filterable-enum 0.1.2

A library for generating filterable enums (Combining bitflags and discriminated unions)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![warn(clippy::all, clippy::nursery)]

pub use enumflags2;

pub use filterable_enum_derive::FilterableEnum;

pub trait FilterableEnum<Enum> {
    type Id;
    type Filter: EnumFilter<Self::Id>;
    fn filterable_id(&self) -> Self::Id;
    fn filter_ref(&self, filter: impl Into<Self::Filter>) -> Option<&Enum>;
    fn filter_and_take(self, filter: impl Into<Self::Filter>) -> Option<Enum>;
}

pub trait EnumFilter<Id> {
    fn contains(&self, id: Id) -> bool;
}