pub struct EnumSize<T: Enumoid>(/* private fields */);
Expand description
A counter between 0 and the number of values inhabiting T
.
Implementations§
source§impl<T: Enumoid> EnumSize<T>
impl<T: Enumoid> EnumSize<T>
pub const EMPTY: EnumSize<T> = _
pub const FULL: EnumSize<T> = _
pub fn from_last_value(value: T) -> Self
pub fn from_usize(sz: usize) -> Option<Self>
pub fn into_word(&self) -> T::Word
pub fn into_usize(&self) -> usize
pub fn into_last_value(&self) -> Option<T>
sourcepub fn next_index(&self, index: EnumIndex<T>) -> Option<EnumIndex<T>>
pub fn next_index(&self, index: EnumIndex<T>) -> Option<EnumIndex<T>>
sourcepub fn prev_index(&self, index: EnumIndex<T>) -> Option<EnumIndex<T>>
pub fn prev_index(&self, index: EnumIndex<T>) -> Option<EnumIndex<T>>
sourcepub fn next_index_wrapped(&self, index: EnumIndex<T>) -> EnumIndex<T>
pub fn next_index_wrapped(&self, index: EnumIndex<T>) -> EnumIndex<T>
Returns the next index or wraps around to the beginning.
§Panics
Panics if the value is beyond the size.
sourcepub fn next_wrapped(&self, value: T) -> T
pub fn next_wrapped(&self, value: T) -> T
Returns the next element or wraps around to the beginning.
§Panics
Panics if the value is beyond the size.
sourcepub fn prev_index_wrapped(&self, index: EnumIndex<T>) -> EnumIndex<T>
pub fn prev_index_wrapped(&self, index: EnumIndex<T>) -> EnumIndex<T>
Returns the previous index or wraps around to the end.
§Panics
Panics if the value is beyond the size.
sourcepub fn prev_wrapped(&self, value: T) -> T
pub fn prev_wrapped(&self, value: T) -> T
Returns the previous element or wraps around to the end.
§Panics
Panics if the value is beyond the size.
pub fn contains_index(&self, index: EnumIndex<T>) -> bool
pub fn contains(&self, value: T) -> bool
pub fn iter( &self ) -> Map<<T as Enumoid>::WordRange, fn(_: <T as Enumoid>::Word) -> T> ⓘ
pub fn iter_until( &self, until: T ) -> Map<<T as Enumoid>::WordRange, fn(_: <T as Enumoid>::Word) -> T> ⓘ
pub fn iter_from( &self, from: T ) -> Map<<T as Enumoid>::WordRange, fn(_: <T as Enumoid>::Word) -> T> ⓘ
pub fn iter_from_until( &self, from: T, until: T ) -> Map<<T as Enumoid>::WordRange, fn(_: <T as Enumoid>::Word) -> T> ⓘ
Trait Implementations§
source§impl<T: Ord + Enumoid> Ord for EnumSize<T>
impl<T: Ord + Enumoid> Ord for EnumSize<T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq + Enumoid> PartialEq for EnumSize<T>
impl<T: PartialEq + Enumoid> PartialEq for EnumSize<T>
source§impl<T: PartialOrd + Enumoid> PartialOrd for EnumSize<T>where
T::Word: PartialOrd,
impl<T: PartialOrd + Enumoid> PartialOrd for EnumSize<T>where
T::Word: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: Enumoid> Copy for EnumSize<T>
impl<T: Eq + Enumoid> Eq for EnumSize<T>
impl<T: Enumoid> StructuralPartialEq for EnumSize<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for EnumSize<T>
impl<T> Send for EnumSize<T>
impl<T> Sync for EnumSize<T>
impl<T> Unpin for EnumSize<T>
impl<T> UnwindSafe for EnumSize<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more