pub trait DefensiveOption<T> {
    fn defensive_map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(
        self,
        default: D,
        f: F
    ) -> U; fn defensive_ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E>; fn defensive_ok_or<E>(self, err: E) -> Result<T, E>; fn defensive_map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U>; }
Expand description

Subset of methods similar to Defensive that can only work for a Option.

Required Methods§

Potentially map and unpack the value to something else (U), or call the default callback if None, which should never happen.

Defensively transform this option to a result, mapping None to the return value of an error closure.

Defensively transform this option to a result, mapping None to a default value.

Exactly the same as map, but it prints the appropriate warnings if the value being mapped is None.

Implementations on Foreign Types§

Implementors§