flex_alloc::capacity

Trait Index

Source
pub trait Index:
    Copy
    + Clone
    + Debug
    + Display
    + Into<usize>
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Send
    + Sync
    + Sized
    + 'static {
    const ZERO: Self;
    const MAX_USIZE: usize;

    // Required methods
    fn from_usize(val: usize) -> Self;
    fn try_from_usize(val: usize) -> Option<Self>;
    fn saturating_add(self, val: usize) -> Self;
    fn saturating_sub(self, val: usize) -> Self;
    fn saturating_mul(self, val: usize) -> Self;

    // Provided method
    fn to_usize(self) -> usize { ... }
}
Expand description

Types which may be used to index and define the length and capacity of collections.

Required Associated Constants§

Source

const ZERO: Self

The zero value

Source

const MAX_USIZE: usize

The maximum representable value of this type as a usize

Required Methods§

Source

fn from_usize(val: usize) -> Self

Create an instance of this type from a usize, panicking if the bounds are exceeded

Source

fn try_from_usize(val: usize) -> Option<Self>

Try to create an instance of this type from a usize

Source

fn saturating_add(self, val: usize) -> Self

Add a usize without exceeding the bounds of this type

Source

fn saturating_sub(self, val: usize) -> Self

Subtract a usize without exceeding the bounds of this type

Source

fn saturating_mul(self, val: usize) -> Self

Multiply by a usize without exceeding the bounds of this type

Provided Methods§

Source

fn to_usize(self) -> usize

Convert this instance into a usize

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 Index for u8

Source§

const ZERO: Self = 0u8

Source§

const MAX_USIZE: usize = 255usize

Source§

fn from_usize(val: usize) -> Self

Source§

fn try_from_usize(val: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

fn saturating_add(self, val: usize) -> Self

Source§

fn saturating_sub(self, val: usize) -> Self

Source§

fn saturating_mul(self, val: usize) -> Self

Source§

impl Index for usize

Source§

const ZERO: Self = 0usize

Source§

const MAX_USIZE: usize = 4_294_967_295usize

Source§

fn from_usize(val: usize) -> Self

Source§

fn try_from_usize(val: usize) -> Option<Self>

Source§

fn saturating_add(self, val: usize) -> Self

Source§

fn saturating_sub(self, val: usize) -> Self

Source§

fn saturating_mul(self, val: usize) -> Self

Implementors§