finite_repr

Trait FiniteValue

Source
pub trait FiniteValue:
    Copy
    + Add<Self, Output = Self>
    + Div<Self, Output = Self>
    + Mul<Self, Output = Self>
    + Rem<Self, Output = Self>
    + Sub<Self, Output = Self>
    + PartialOrd {
    const MIN: Self;
    const ONE: Self;
    const ZERO: Self;

    // Required methods
    fn from_usize(other: usize) -> Option<Self>;
    fn into_usize(other: Self) -> Option<usize>;

    // Provided methods
    fn inc(self) -> Self { ... }
    fn dec(self) -> Self { ... }
}

Required Associated Constants§

Source

const MIN: Self

Source

const ONE: Self

Source

const ZERO: Self

Required Methods§

Source

fn from_usize(other: usize) -> Option<Self>

Source

fn into_usize(other: Self) -> Option<usize>

Provided Methods§

Source

fn inc(self) -> Self

Source

fn dec(self) -> Self

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 FiniteValue for i8

Source§

const MIN: i8 = -128i8

Source§

const ONE: i8 = 1i8

Source§

const ZERO: i8 = 0i8

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for i16

Source§

const MIN: i16 = -32_768i16

Source§

const ONE: i16 = 1i16

Source§

const ZERO: i16 = 0i16

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for i32

Source§

const MIN: i32 = -2_147_483_648i32

Source§

const ONE: i32 = 1i32

Source§

const ZERO: i32 = 0i32

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for i64

Source§

const MIN: i64 = -9_223_372_036_854_775_808i64

Source§

const ONE: i64 = 1i64

Source§

const ZERO: i64 = 0i64

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for i128

Source§

const MIN: i128 = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

Source§

const ONE: i128 = 1i128

Source§

const ZERO: i128 = 0i128

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for u8

Source§

const MIN: u8 = 0u8

Source§

const ONE: u8 = 1u8

Source§

const ZERO: u8 = 0u8

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for u16

Source§

const MIN: u16 = 0u16

Source§

const ONE: u16 = 1u16

Source§

const ZERO: u16 = 0u16

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for u32

Source§

const MIN: u32 = 0u32

Source§

const ONE: u32 = 1u32

Source§

const ZERO: u32 = 0u32

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for u64

Source§

const MIN: u64 = 0u64

Source§

const ONE: u64 = 1u64

Source§

const ZERO: u64 = 0u64

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Source§

impl FiniteValue for u128

Source§

const MIN: u128 = 0u128

Source§

const ONE: u128 = 1u128

Source§

const ZERO: u128 = 0u128

Source§

fn from_usize(other: usize) -> Option<Self>

Source§

fn into_usize(other: Self) -> Option<usize>

Implementors§