Skip to main content

FirstOrDefault

Trait FirstOrDefault 

Source
pub trait FirstOrDefault {
    type Item;

    // Required method
    fn first_or_default(&self) -> Self::Item;
}
Expand description

Provides first-item lookup with a default value for an empty sequence.

Required Associated Types§

Required Methods§

Source

fn first_or_default(&self) -> Self::Item

Returns the first item or the default value.

Implementations on Foreign Types§

Source§

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

Source§

type Item = T

Source§

fn first_or_default(&self) -> T

Implementors§