Skip to main content

Indexed

Trait Indexed 

Source
pub trait Indexed<T> {
    type Element: ?Sized;

    // Required method
    fn get(&self, i: T) -> Option<&Self::Element>;
}
Expand description

Trait for indexing into an array

Required Associated Types§

Source

type Element: ?Sized

Elements of the array

Required Methods§

Source

fn get(&self, i: T) -> Option<&Self::Element>

Gets a ref to a value based on n index, returns None if the current Value isn’t an Array or doesn’t contain the index it was asked for.

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, I> Indexed<I> for Vec<T>
where I: SliceIndex<[T]>,

Source§

type Element = <I as SliceIndex<[T]>>::Output

Source§

fn get(&self, i: I) -> Option<&<Vec<T> as Indexed<I>>::Element>

Implementors§