tryFind<E extends Object> method

Result<Option<T>, E> tryFind<E extends Object>(
  1. Result<bool, E> f(
    1. T
    )
)

Applies function to the elements of iterator and returns the first true result or the first error.

Implementation

Result<Option<T>, E> tryFind<E extends Object>(
    Result<bool, E> Function(T) f) {
  for (final res in this) {
    final found = f(res);
    if (found.isErr()) {
      return found.intoUnchecked();
    }
    if (found.unwrap()) {
      return Ok(Some(res));
    }
  }
  return Ok(None);
}