typst_utils

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", so this trait is not object safe.

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§