All tests if every element of the Iterator matches a predicate. An empty Iterator returns true.
(it Iterator[T], pred func(T) bool)
| 425 | // All tests if every element of the Iterator matches a predicate. An empty |
| 426 | // Iterator returns true. |
| 427 | func All[T any](it Iterator[T], pred func(T) bool) bool { |
| 428 | v := it.Next() |
| 429 | for v.IsSome() { |
| 430 | if !pred(v.Unwrap()) { |
| 431 | return false |
| 432 | } |
| 433 | v = it.Next() |
| 434 | } |
| 435 | return true |
| 436 | } |
| 437 | |
| 438 | // Any tests if any element of the Iterator matches a predicate. An empty |
| 439 | // Iterator returns false. |