Skip to main content

Get

Trait Get 

Source
pub trait Get<Idx>: Collection {
    type Output: ?Sized;

    // Required method
    fn get(&self, index: Idx) -> Option<&Self::Output>;

    // Provided methods
    fn get_or_panic(&self, index: Idx) -> &Self::Output { ... }
    unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output { ... }
    fn is_index_valid(&self, index: Idx) -> bool { ... }
    fn is_index_invalid(&self, index: Idx) -> bool { ... }
    fn contains(&self, index: Idx) -> bool { ... }
}
Expand description

The collection have a quick way to access each element, where the index is copyable

Required Associated Types§

Required Methods§

Source

fn get(&self, index: Idx) -> Option<&Self::Output>

Returns a reference to the value.

Provided Methods§

Source

fn get_or_panic(&self, index: Idx) -> &Self::Output

Returns a reference to the value.

Source

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Returns a reference to the value.

Source

fn is_index_valid(&self, index: Idx) -> bool

True if get(index) return Some, false otherwise.

Source

fn is_index_invalid(&self, index: Idx) -> bool

True if get(index) return None, false otherwise.

Source

fn contains(&self, index: Idx) -> bool

Implementations on Foreign Types§

Source§

impl<Idx> Get<Idx> for &str
where Idx: SliceIndex<str>,

Source§

type Output = <str as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx> Get<Idx> for &mut str
where Idx: SliceIndex<str>,

Source§

type Output = <str as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx> Get<Idx> for str
where Idx: SliceIndex<str>,

Source§

type Output = <str as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx> Get<Idx> for String
where Idx: SliceIndex<str>,

Source§

type Output = <str as Get<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

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

Source§

type Output = <[T] as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx, T> Get<Idx> for &mut [T]
where Idx: SliceIndex<[T]>,

Source§

type Output = <[T] as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

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

Source§

type Output = <[T] as Index<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx, T> Get<Idx> for Vec<T>
where [T]: Get<Idx>,

Source§

type Output = <[T] as Get<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<Idx, T, const N: usize> Get<Idx> for [T; N]
where [T]: Get<Idx>,

Source§

type Output = <[T] as Get<Idx>>::Output

Source§

fn get(&self, index: Idx) -> Option<&Self::Output>

Source§

unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output

Source§

impl<K, Q> Get<&Q> for BTreeSet<K>
where K: Borrow<Q> + Ord, Q: ?Sized + Ord,

Source§

type Output = K

Source§

fn get(&self, k: &Q) -> Option<&Self::Output>

Source§

impl<K, S, Q> Get<&Q> for HashSet<K, S>
where K: Borrow<Q> + Eq + Hash, Q: ?Sized + Hash + Eq, S: BuildHasher,

Available on crate feature std only.
Source§

type Output = K

Source§

fn get(&self, k: &Q) -> Option<&Self::Output>

Source§

impl<K, V, Q> Get<&Q> for BTreeMap<K, V>
where K: Borrow<Q> + Ord, Q: ?Sized + Ord,

Source§

type Output = V

Source§

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

Source§

impl<K, V, S, Q> Get<&Q> for HashMap<K, V, S>
where K: Borrow<Q> + Eq + Hash, Q: ?Sized + Hash + Eq, S: BuildHasher,

Available on crate feature std only.
Source§

type Output = V

Source§

fn get(&self, k: &Q) -> Option<&Self::Output>

Source§

impl<T> Get<usize> for VecDeque<T>

Source§

type Output = <VecDeque<T> as Index<usize>>::Output

Source§

fn get(&self, index: usize) -> Option<&Self::Output>

Implementors§