Skip to main content

EnumSetType

Trait EnumSetType 

Source
pub trait EnumSetType:
    Copy
    + Eq
    + 'static {
    const VARIANTS: u32;

    // Required methods
    fn to_bit(self) -> u32;
    fn from_bit(bit: u32) -> Self;
}
Expand description

An enum whose variants can be collected into an EnumSet.

Derive it with #[derive(EnumSetType)], alongside Clone, Copy, PartialEq and Eq.

The set is backed by a u64, so an enum may have at most 64 variants, and it must be a plain C-like enum with no fields.

Required Associated Constants§

Source

const VARIANTS: u32

Number of variants in the enum.

Required Methods§

Source

fn to_bit(self) -> u32

Index of the bit representing this variant.

Source

fn from_bit(bit: u32) -> Self

The variant a bit index stands for.

§Panics

If bit is not below Self::VARIANTS.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§