orElse

Undocumented in source. Be warned that the author may not have intended to support it.
ref
orElse
(
alias pred
T
)
(
return auto ref scope Optional!T optional
)
if (
is(typeof(pred()) == Optional!T)
)

Examples

// source: https://doc.rust-lang.org/std/option/enum.Option.html#method.or_else
alias O = Optional!string;

auto nobody = function O() => none;
auto vikings = function O() => "vikings".some;

assert(O.some("barbarians").orElse!vikings == "barbarians".some);
assert(O.none.orElse!vikings == "vikings".some);
assert(O.none.orElse!nobody == none);

Meta