tryCollect method

Result<List<T>, E> tryCollect()

Transforms an iterator into a collection, short circuiting if a Err is encountered.

Implementation

Result<List<T>, E> tryCollect() {
  final result = <T>[];
  for (final res in this) {
    if (res.isErr()) {
      return res.intoUnchecked();
    }
    result.add(res.unwrap());
  }
  return Ok(result);
}