fmapOrElse

Undocumented in source.
template fmapOrElse(alias pred, alias orElse)
fmapOrElse
(
T
E
)
(
auto ref scope Result!(T, E) result
)
if (
is(typeof(orElse(E.init)) : typeof(pred(T.init)))
)

Members

Functions

fmapOrElse
auto fmapOrElse(Result!(T, E) result)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

// source: https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or_else
auto k = 21;

auto x = Result!string.ok("foo");
assert(x.fmapOrElse!(str => str.length, e => k * 2) == 3);

auto y = Result!string.err("bar");
assert(y.fmapOrElse!(str => str.length, e => k * 2) == 42);

Meta