Get

Trait Get 

Source
pub trait Get<Q> {
    type Key: ?Sized;
    type Output: ?Sized;

    // Required method
    fn get(&self, index: Q) -> Option<&Self::Output>
       where Self::Key: Borrow<Q>;
}
Expand description

Get defines an interface for entities that can be accessed by a key; the design is similar to the Index trait in the standard library, however, uses the Borrow trait to allow for more flexible key types.

Required Associated Types§

Required Methods§

Source

fn get(&self, index: Q) -> Option<&Self::Output>
where Self::Key: Borrow<Q>,

returns a reference to the element at the specified index.

Implementations on Foreign Types§

Source§

impl<Q, K, U, Y> Get<Q> for &U
where U: Get<Q, Key = K, Output = Y>,

Source§

type Key = <U as Get<Q>>::Key

Source§

type Output = Y

Source§

fn get(&self, index: Q) -> Option<&<&U as Get<Q>>::Output>
where <&U as Get<Q>>::Key: Borrow<Q>,

Source§

impl<Q, T> Get<Q> for [T]
where Q: SliceIndex<[T]>,

Source§

type Key = usize

Source§

type Output = <Q as SliceIndex<[T]>>::Output

Source§

fn get(&self, index: Q) -> Option<&<[T] as Get<Q>>::Output>
where <[T] as Get<Q>>::Key: Borrow<Q>,

Implementors§