The result
if it is Ok
, or the Result
returned by elseFn
if result
is an `Err.
Like or
, but using a function to construct the alternative
Result
.
Sometimes you need to perform an operation using the error
value (and
possibly other data in the environment) to construct the fallback value. In
these situations, you can pass a function (which may be a closure) as the
elseFn
to generate the fallback Result<T>
. It can then transform the data
in the Err
to something usable as an Ok
, or generate a new
Err
instance as appropriate.
Useful for transforming failures to usable data.
The result
if it is Ok
, or the Result
returned by elseFn
if result
is an `Err.
Like
or
, but using a function to construct the alternativeResult
.Sometimes you need to perform an operation using the
error
value (and possibly other data in the environment) to construct the fallback value. In these situations, you can pass a function (which may be a closure) as theelseFn
to generate the fallbackResult<T>
. It can then transform the data in theErr
to something usable as anOk
, or generate a newErr
instance as appropriate.Useful for transforming failures to usable data.