MCPcopy Create free account
hub / github.com/Soft/iter / All

Function All

iterator.go:427–436  ·  view source on GitHub ↗

All tests if every element of the Iterator matches a predicate. An empty Iterator returns true.

(it Iterator[T], pred func(T) bool)

Source from the content-addressed store, hash-verified

425// All tests if every element of the Iterator matches a predicate. An empty
426// Iterator returns true.
427func 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.

Callers 1

TestAllFunction · 0.85

Calls 3

IsSomeMethod · 0.80
UnwrapMethod · 0.80
NextMethod · 0.65

Tested by 1

TestAllFunction · 0.68