[][src]Trait plain_enum::TPlainEnum

pub trait TPlainEnum: Sized {
    const SIZE: usize;

    unsafe fn from_usize(u: usize) -> Self;
fn to_usize(self) -> usize; fn valid_usize(u: usize) -> bool { ... }
fn checked_from_usize(u: usize) -> Option<Self> { ... }
fn wrapped_from_usize(u: usize) -> Self { ... }
fn wrapped_difference_usize(self, e_other: Self) -> usize { ... }
fn wrapped_difference(self, e_other: Self) -> SWrappedDifference<Self> { ... }
fn values() -> Map<Range<usize>, fn(_: usize) -> Self> { ... }
fn wrapping_add(self, n_offset: usize) -> Self { ... }
fn map_from_fn<F, T>(func: F) -> EnumMap<Self, T>
    where
        F: FnMut(Self) -> T,
        Self: TInternalEnumMapType<T>
, { ... }
fn map_from_raw<V>(a: Self::InternalEnumMapType) -> EnumMap<Self, V>
    where
        Self: TInternalEnumMapType<V>
, { ... } }

This trait is implemented by enums declared via the plain_enum_mod macro. Do not implement it yourself, but use this macro.

Associated Constants

const SIZE: usize

Arity, i.e. the smallest usize not representable by the enum.

Loading content...

Required methods

unsafe fn from_usize(u: usize) -> Self

Converts u to the associated enum value. Assumes that u is a valid value for the enum, and is, thus, unsafe.

fn to_usize(self) -> usize

Converts the enum to its numerical representation.

Loading content...

Provided methods

fn valid_usize(u: usize) -> bool

Checks whether u is the numerical representation of a valid enum value.

fn checked_from_usize(u: usize) -> Option<Self>

Converts u to the associated enum value. if u is a valid value for the enum.

fn wrapped_from_usize(u: usize) -> Self

Converts u to the associated enum value, but wraps u it before conversion (i.e. it applies the modulo operation with a modulus equal to the arity of the enum before converting).

fn wrapped_difference_usize(self, e_other: Self) -> usize

Computes the difference between two enum values, wrapping around if necessary.

fn wrapped_difference(self, e_other: Self) -> SWrappedDifference<Self>

Computes the difference between two enum values, wrapping around if necessary, and converts it to an enum value.

fn values() -> Map<Range<usize>, fn(_: usize) -> Self>

Returns an iterator over the enum's values.

fn wrapping_add(self, n_offset: usize) -> Self

Adds a number to the enum, wrapping.

fn map_from_fn<F, T>(func: F) -> EnumMap<Self, T> where
    F: FnMut(Self) -> T,
    Self: TInternalEnumMapType<T>, 

Creates a enum map from enum values to a type, determined by func. The map will contain the results of applying func to each enum value.

fn map_from_raw<V>(a: Self::InternalEnumMapType) -> EnumMap<Self, V> where
    Self: TInternalEnumMapType<V>, 

Creates a enum map from a raw array.

Loading content...

Implementations on Foreign Types

impl TPlainEnum for bool[src]

impl TPlainEnum for ()[src]

Loading content...

Implementors

Loading content...