Skip to main content

Index

Trait Index 

Source
pub trait Index: IndexCore {
    type FixedWidth: Index;
    type Signed: SignedIndex;

    const BITS: u32 = _;

    // Provided methods
    fn canonicalize(slice: &[Self]) -> &[Self::FixedWidth] { ... }
    fn canonicalize_mut(slice: &mut [Self]) -> &mut [Self::FixedWidth] { ... }
    fn from_signed(value: Self::Signed) -> Self { ... }
    fn to_signed(self) -> Self::Signed { ... }
    fn sum_nonnegative(slice: &[Self]) -> Option<Self> { ... }
}

Provided Associated Constants§

Source

const BITS: u32 = _

Required Associated Types§

Source

type FixedWidth: Index

Equally-sized index type with a fixed size (no usize).

Source

type Signed: SignedIndex

Equally-sized signed index type.

Provided Methods§

Source

fn canonicalize(slice: &[Self]) -> &[Self::FixedWidth]

Convert a reference to a slice of Self to fixed width types.

Source

fn canonicalize_mut(slice: &mut [Self]) -> &mut [Self::FixedWidth]

Convert a mutable reference to a slice of Self to fixed width types.

Source

fn from_signed(value: Self::Signed) -> Self

Convert a signed value to an unsigned one.

Source

fn to_signed(self) -> Self::Signed

Convert an unsigned value to a signed one.

Source

fn sum_nonnegative(slice: &[Self]) -> Option<Self>

Sum values while checking for overflow.

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 u32

Source§

impl Index for u64

Available on 64-bit only.
Source§

impl Index for usize

Implementors§