Skip to main content

ElementAtOrDefault

Trait ElementAtOrDefault 

Source
pub trait ElementAtOrDefault {
    type Item;

    // Required method
    fn elementat_or_default(&self, index: usize) -> Self::Item;
}
Expand description

Provides indexed lookup with a default value when the index is out of range.

Required Associated Types§

Required Methods§

Source

fn elementat_or_default(&self, index: usize) -> Self::Item

Returns the item at index, or T::default() when no item exists there.

Implementations on Foreign Types§

Source§

impl<T> ElementAtOrDefault for [T]
where T: Default + Clone,

Source§

type Item = T

Source§

fn elementat_or_default(&self, index: usize) -> Self::Item

Implementors§