Trait plain_enum::TPlainEnum
[−]
[src]
pub trait TPlainEnum: Sized { const SIZE: usize; fn valid_usize(u: usize) -> bool; fn from_usize(u: usize) -> Self; fn checked_from_usize(u: usize) -> Option<Self>; fn wrapped_from_usize(u: usize) -> Self; fn wrapped_difference(self, e_other: Self) -> usize; fn to_usize(self) -> usize; fn wrapping_add(self, n_offset: usize) -> Self; fn values() -> Map<Range<usize>, fn(_: usize) -> Self> { ... } }
This trait is implemented by enums declared via the plain_enum_mod
macro.
Do not implement it yourself, but use this macro.
Associated Constants
Required Methods
fn valid_usize(u: usize) -> bool
Checks whether u
is the numerical representation of a valid enum value.
fn from_usize(u: usize) -> Self
Converts u
to the associated enum value. assert
s that u
is a valid value for the enum.
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(self, e_other: Self) -> usize
Computes the difference between two enum values, wrapping around if necessary.
fn to_usize(self) -> usize
Converts the enum to its numerical representation.
fn wrapping_add(self, n_offset: usize) -> Self
Adds a number to the enum, wrapping.
Provided Methods
Implementors
impl TPlainEnum for ExampleEnum