Skip to main content

OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
    // Required method
    fn map_or_default<U: Default, F>(self, f: F) -> U
       where F: FnOnce(T) -> U;
}
Expand description

Extra methods for Option.

Required Methods§

Source

fn map_or_default<U: Default, F>(self, f: F) -> U
where F: FnOnce(T) -> U,

Maps an Option<T> to U by applying a function to a contained value (if Some) or returns a default (if None).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> OptionExt<T> for Option<T>

Source§

fn map_or_default<U: Default, F>(self, f: F) -> U
where F: FnOnce(T) -> U,

Implementors§