Trait KeyPathIndexable

Source
pub trait KeyPathIndexable<T>
where T: ?Sized,
{ type Output; // Required method fn idx(self) -> Self::Output; }
Expand description

The trait that powers indexing via key-path. There are not separate traits for move-by-index, mut-ref-by-index, and ref-by-index. Instead, KeyPathIndexable is implemented for T, &T, and &mut T separately.

Required Associated Types§

Required Methods§

Source

fn idx(self) -> Self::Output

Implementations on Foreign Types§

Source§

impl<'t, const N: usize, T> KeyPathIndexable<UsizeKeyPath<N>> for &'t T
where T: Index<usize>,

Source§

type Output = &'t <T as Index<usize>>::Output

Source§

fn idx(self) -> Self::Output

Source§

impl<'t, const N: usize, T> KeyPathIndexable<UsizeKeyPath<N>> for &'t mut T
where T: IndexMut<usize>,

Source§

type Output = &'t mut <T as Index<usize>>::Output

Source§

fn idx(self) -> Self::Output

Source§

impl<const N: usize, T> KeyPathIndexable<UsizeKeyPath<N>> for Vec<T>

A special-cased implementation for move-by-indexing with a Vec, as there is no standard trait to implement such a thing (since Index and IndexMut only allow ref-by-index and mut-ref-by-index, respectively.

Source§

type Output = T

Source§

fn idx(self) -> Self::Output

Implementors§