Trait OptionExt

Source
pub trait OptionExt<T> {
    // Required methods
    fn unwrap_or_auto<T2>(self, default: T2) -> T2
       where T2: From<T>;
    fn map_auto<T2>(self) -> Option<T2>
       where T2: From<T>;
    fn ok_or_auto<O, E>(self, err: E) -> Result<O, E>
       where O: From<T>;
}
Expand description

An extension trait for Options.

Required Methods§

Source

fn unwrap_or_auto<T2>(self, default: T2) -> T2
where T2: From<T>,

Unwraps the option, or returns a default value (converted to the option’s type).

Source

fn map_auto<T2>(self) -> Option<T2>
where T2: From<T>,

Maps the option to another option type.

Source

fn ok_or_auto<O, E>(self, err: E) -> Result<O, E>
where O: From<T>,

Unwraps the option, or returns an error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

fn unwrap_or_auto<T2>(self, default: T2) -> T2
where T2: From<T>,

Source§

fn map_auto<T2>(self) -> Option<T2>
where T2: From<T>,

Source§

fn ok_or_auto<O, E>(self, err: E) -> Result<O, E>
where O: From<T>,

Implementors§