OptionConvenience<T> extension
Convenience methods for handling Options.
Help is wanted here! Please open PRs to add any methods you want! When possible, try to follow the function names in Rust for Option:
- on
-
- Option<
T>
- Option<
Methods
-
asNullable(
) → T? -
Available on Option<
Returns Some.value orT> , provided by the OptionConvenience extensionnull
for None. -
map<
R> (R mapper(T)) → Option< R> -
Available on Option<
Maps an OptionT> , provided by the OptionConvenience extension -
unwrapOr(
T defaultValue) → T -
Available on Option<
Returns Some.value ifT> , provided by the OptionConvenience extensionthis
is a Some. Otherwise, returnsdefaultValue
(when None). -
unwrapOrElse(
T defaultFn()) → T -
Available on Option<
Returns Some.value ifT> , provided by the OptionConvenience extensionthis
is a Some. Otherwise, calls and returns the result ofdefaultFn
(when None).