gen_value

Trait Incrementable

Source
pub trait Incrementable: PartialOrd + Sized {
    // Required methods
    fn next(&self) -> Option<Self>;
    fn max() -> Option<Self>;
}
Expand description

A type which can attempt to return the smallest value which is still bigger than the current value.

It is used for index and generation type parameters to find the next index or the next generation respectively.

§Examples

An implementation of Incrementable has been made for all integer types.

use gen_value::Incrementable;

let value: u32 = 1;
assert_eq!(value.next(), Some(2));
assert_eq!(u32::MAX.next(), None);

Required Methods§

Source

fn next(&self) -> Option<Self>

Returns the next value, if available.

Source

fn max() -> Option<Self>

Returns the maximum value, if available.

For generations, the maximum value serves as an indicator that the index can no longer be used (tombstone value). The last generation used would be max() - 1.

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.

Implementations on Foreign Types§

Source§

impl Incrementable for i8

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for i16

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for i32

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for i64

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for isize

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for u8

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for u16

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for u32

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for u64

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Source§

impl Incrementable for usize

Source§

fn next(&self) -> Option<Self>

Source§

fn max() -> Option<Self>

Implementors§