Skip to main content

SizedIndex

Trait SizedIndex 

Source
pub trait SizedIndex<I: Uint>: Index<I> {
    // Required method
    fn length(&self) -> I;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn last(&self) -> Option<&Self::Output> { ... }
    fn index_iter(self) -> IndexIter<I, Self> ⓘ
       where Self: Sized { ... }
}
Expand description

A container indexed by I from 0 up to length.

The length is fixed: it does not change for as long as the container is held, so IndexIter can promise an exact size_hint and stay fused. A container with interior mutability that could change its length must not implement this trait.

Required Methods§

Source

fn length(&self) -> I

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

fn last(&self) -> Option<&Self::Output>

Source

fn index_iter(self) -> IndexIter<I, Self> ⓘ
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> SizedIndex<usize> for [T]

Source§

fn length(&self) -> usize

Implementors§

Source§

impl<W: ContainerWrapper> SizedIndex<u32> for W