Trait aoko::no_std::functions::ext::OptionExt [−][src]
pub trait OptionExt<T> {
fn or_else_some(self, f: impl FnOnce() -> T) -> Self;
}
Expand description
This trait is to implement some extension functions for Option<T>
type.
Required methods
fn or_else_some(self, f: impl FnOnce() -> T) -> Self
Implementations on Foreign Types
This function is similar to or_else
,
but convert closure result to Some
automatically.
Examples
use aoko::no_std::functions::ext::*;
assert_eq!(Some(0), None::<u8>.or_else_some(|| 0));