pub unsafe trait BigEnumSetType: Copy + Eq + BigEnumSetTypePrivate { }
Expand description

The trait used to define enum types that may be used with BigEnumSet.

This trait should be implemented using #[derive(BigEnumSetType)]. Its internal structure is not stable, and may change at any time.

Custom Derive

Any C-like enum is supported, as long as there are no more than 65536 variants in the enum, and no variant discriminant is larger than 65535.

The custom derive for BigEnumSetType automatically creates implementations of Sub, BitAnd, BitOr, BitXor, and Not allowing the enum to be used as if it were an BigEnumSet in expressions. This can be disabled by adding an #[big_enum_set(no_ops)] attribute to the enum.

The custom derive for BigEnumSetType automatically implements Copy, Clone, Eq, and PartialEq on the enum. These are required for the BigEnumSet to function.

Attributes controlling the serialization of BigEnumSet are documented in its documentation.

Examples

Deriving a plain BigEnumSetType:

#[derive(BigEnumSetType)]
pub enum Enum {
   A, B, C, D, E, F, G,
}

Deriving a sparse BigEnumSetType:

#[derive(BigEnumSetType)]
pub enum SparseEnum {
   A = 10, B = 20, C = 30, D = 127,
}

Deriving an BigEnumSetType without adding ops:

#[derive(BigEnumSetType)]
#[big_enum_set(no_ops)]
pub enum NoOpsEnum {
   A, B, C, D, E, F, G,
}

Implementors§