recover method

Result<T> recover(
  1. T recovery(
    1. Failure failure
    )
)

Synchronous counterpart to FutureResultX.recover. If this is an Error, substitutes a default success value computed from the failure; otherwise propagates the Success unchanged.

Implementation

Result<T> recover(T Function(Failure failure) recovery) => switch (this) {
      Success<T>() => this,
      Error<T>(:final failure) => Success<T>(recovery(failure)),
    };