match<R> method

R match<R>({
  1. required R onSuccess(
    1. Success<T> success
    ),
  2. required R onFailure(
    1. Failure failure
    ),
})

Performs state matching similarly to fold, but explicitly passes the underlying granular Success context object rather than just its unwrapped value.

Implementation

R match<R>({
  required R Function(Success<T> success) onSuccess,
  required R Function(Failure failure) onFailure,
}) =>
    switch (this) {
      _SuccessResult<T>(success: final success) => onSuccess(success),
      _FailureResult<T>(failure: final failure) => onFailure(failure),
    };