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§

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).

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

Maps the option to another option type.

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

Unwraps the option, or returns an error.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

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

§

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>,

Implementors§