Skip to main content

mixed_enum_set

Macro mixed_enum_set 

Source
macro_rules! mixed_enum_set {
    ($($internal:tt)*) => { ... };
}
Expand description

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

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

This macro accepts trailing |s to allow easier use in other macros.

§Examples

const CONST_SET: MixedEnumSet<Enum> = mixed_enum_set!(Enum::A | Enum::B);
assert_eq!(CONST_SET, MixedEnumSet::from(Enum::A | Enum::B));

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

let type_error = enum_set!(Enum::A | Enum2::B);