Trait mina::State

pub trait State: Sized {
    const LENGTH: usize;

    // Required methods
    fn from_usize(value: usize) -> Self;
    fn into_usize(self) -> usize;
}
Expand description

Enum mapping type.

This trait is implemented by #[derive(Enum)].

This trait is also implemented by bool and u8. While u8 is strictly speaking not an actual enum, there are good reasons to consider it like one, as array of u8 keys is a relatively common pattern.

Required Associated Constants§

const LENGTH: usize

Length of the enum.

Required Methods§

fn from_usize(value: usize) -> Self

Takes an usize, and returns an element matching into_usize function.

fn into_usize(self) -> usize

Returns an unique identifier for a value within range of 0..Array::LENGTH.

Implementations on Foreign Types§

§

impl Enum for u8

§

const LENGTH: usize = 256usize

§

fn from_usize(value: usize) -> u8

§

fn into_usize(self) -> usize

§

impl Enum for ()

§

const LENGTH: usize = 1usize

§

fn from_usize(value: usize)

§

fn into_usize(self) -> usize

§

impl Enum for Infallible

§

const LENGTH: usize = 0usize

§

fn from_usize(_: usize) -> Infallible

§

fn into_usize(self) -> usize

§

impl Enum for Ordering

§

const LENGTH: usize = 3usize

§

fn from_usize(value: usize) -> Ordering

§

fn into_usize(self) -> usize

§

impl Enum for bool

§

const LENGTH: usize = 2usize

§

fn from_usize(value: usize) -> bool

§

fn into_usize(self) -> usize

Implementors§