IndexLike

Trait IndexLike 

Source
pub trait IndexLike:
    KeyLike
    + PartialOrd
    + Ord {
    // Required methods
    fn from_usize(value: usize) -> Self;
    fn to_usize(&self) -> usize;
    fn invalid() -> Self;

    // Provided methods
    fn decr(&mut self) { ... }
    fn incr(&mut self) { ... }
    fn is_valid(&self) -> bool { ... }
}
Expand description

A trait for anything we use as a zero-based index.

Required Methods§

Source

fn from_usize(value: usize) -> Self

Convert a usize to the index.

Source

fn to_usize(&self) -> usize

Convert the index to a usize.

Source

fn invalid() -> Self

The invalid (maximal) value.

Provided Methods§

Source

fn decr(&mut self)

Decrement the value.

Source

fn incr(&mut self)

Increment the value.

Source

fn is_valid(&self) -> bool

Is a valid value (not the maximal value).

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§