Trait OptionExt
pub trait OptionExt<T> {
// Required method
fn map_or_default<U, F>(self, f: F) -> U
where U: Default,
F: FnOnce(T) -> U;
}
Expand description
Extra methods for Option
.
Required Methods§
fn map_or_default<U, F>(self, f: F) -> U
fn map_or_default<U, F>(self, f: F) -> 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.