combineResultListWithAllErrors<T, E> function
Implementation
Result<List<T>, List<E>> combineResultListWithAllErrors<T, E>(
List<Result<T, E>> resultList) {
if (resultList.isEmpty) {
resultList = [ok([])] as List<Result<T, E>>;
}
return resultList.fold<Result<List<T>, List<E>>>(
ok<List<T>, List<E>>([]),
(acc, result) => result.isErr()
? acc.isErr()
? acc.mapErr((list) => list..add(result.asErr.error))
: err([result.asErr.error])
: acc.isErr()
? acc
: acc.map((list) => list..add(result.asOk.value)));
}