Skip to main content

Length

Trait Length 

Source
pub trait Length: Seal + Copy {
    const MAX: usize;
    const ZERO: Self;

    // Required methods
    fn from_usize(value: usize) -> Self;
    fn into_usize(self) -> usize;

    // Provided method
    unsafe fn add(self, amount: usize) -> Self { ... }
}

Required Associated Constants§

Source

const MAX: usize

Source

const ZERO: Self

Required Methods§

Source

fn from_usize(value: usize) -> Self

Source

fn into_usize(self) -> usize

Provided Methods§

Source

unsafe fn add(self, amount: usize) -> Self

§Safety

The sum must fit this length representation and therefore usize.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Length for u8

Source§

const MAX: usize

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Self

Source§

fn into_usize(self) -> usize

Source§

impl Length for u16

Source§

const MAX: usize

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Self

Source§

fn into_usize(self) -> usize

Source§

impl Length for u32

Source§

const MAX: usize

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Self

Source§

fn into_usize(self) -> usize

Source§

impl Length for usize

Source§

const MAX: usize = usize::MAX

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Self

Source§

fn into_usize(self) -> usize

Implementors§