tryFind method

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

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

Implementation

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