Macro enumset::enum_set[][src]

macro_rules! enum_set {
    () => { ... };
    ($($value:path)|* $(|)*) => { ... };
    ($enum_name:ty, $($value:path)|* $(|)*) => { ... };
}

Creates a EnumSet literal, which can be used in const contexts.

The syntax used is enum_set!(Type::A | Type::B | Type::C). Each variant must be of the same type, or a error will occur at compile-time.

You may also explicitly state the type of the variants that follow, as in enum_set!(Type, Type::A | Type::B | Type::C).

Examples

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

const EXPLICIT_CONST_SET: EnumSet<Enum> = enum_set!(Enum, Enum::A | Enum::B);
assert_eq!(EXPLICIT_CONST_SET, Enum::A | Enum::B);

This macro is strongly typed. For example, the following will not compile:

This example deliberately fails to compile
let type_error = enum_set!(Enum::A | Enum2::B);