Skip to main content

IndexedEnum

Trait IndexedEnum 

pub trait IndexedEnum:
    Sized
    + Sealed
    + 'static {
    const VARIANTS: &'static [Self];

    // Required method
    fn as_index(&self) -> usize;
}
Expand description

Trait for enums that have fixed indexed variants.

Required Associated Constants§

const VARIANTS: &'static [Self]

A slice containing all the variants in index order.

The exact value is subject to change in any future release.

Required Methods§

fn as_index(&self) -> usize

Returns this variant’s unique zero-based index.

The index satisfies 0 <= self.as_index() < Self::VARIANTS.len().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl IndexedEnum for Category

§

const VARIANTS: &'static [Category]

§

impl IndexedEnum for Reason

§

const VARIANTS: &'static [Reason]