enumset

Macro enum_set_intersection

Source
macro_rules! enum_set_intersection {
    ($value:path $(,)?) => { ... };
    ($value:path, $($rest:path),* $(,)?) => { ... };
}
Expand description

Computes the intersection of multiple enums or constants enumset at compile time.

The syntax used is enum_set_intersection!(ENUM_A, ENUM_B, ENUM_C), computing the equivalent of ENUM_A & ENUM_B & ENUM_C at compile time. Each variant must be of the same type, or an error will occur at compile-time.

ยงExamples

const SET_A: EnumSet<Enum> = enum_set!(Enum::A | Enum::B);
const SET_B: EnumSet<Enum> = enum_set!(Enum::B | Enum::C);
const CONST_SET: EnumSet<Enum> = enum_set_intersection!(SET_A, SET_B);
assert_eq!(CONST_SET, Enum::B);