flatten<T> static method

Result<T> flatten<T>(
  1. Result<Result<T>> result
)

Converts a result of a result to a single result.

If the result is an error, or it is a Result value which is then an error, then a result with that error is returned. Otherwise both levels of results are value results, and a single result with the value is returned.

Implementation

static Result<T> flatten<T>(Result<Result<T>> result) {
  if (result.isValue) return result.asValue!.value;
  return result.asError!;
}