The actual mapOrElse function.
A new Expected object containing the result.
assert(ok(42).mapOrElse!(v => v/2, e => 0) == 21); assert(ok().mapOrElse!(() => true, e => false)); assert(err!int("foo").mapOrElse!(v => v/2, e => 42) == 42); assert(!err("foo").mapOrElse!(() => true, e => false));
Maps a Expected<T, E> to U by applying a function to a contained value, or a fallback function to a contained error value.
Both functions has to be of the same return type.
This function can be used to unpack a successful result while handling an error.