package miter
import "github.com/onsi/gomega/matchers/internal/miter"
Index ¶
- func HasIterators() bool
- func IsIter(it any) bool
- func IsSeq2(it any) bool
- func IterKVTypes(it any) (k, v reflect.Type)
- func IterateKV(it any, yield func(k, v reflect.Value) bool)
- func IterateV(it any, yield func(v reflect.Value) bool)
Functions ¶
func HasIterators ¶
func HasIterators() bool
HasIterators always returns false for Go versions before 1.23.
func IsIter ¶
IsIter returns true if the specified value is a function type that can be range-d over, otherwise false.
We don't use reflect's CanSeq and CanSeq2 directly, as these would return true also for other value types that are range-able, such as integers, slices, et cetera. Here, we aim only at range-able (iterator) functions.
func IsSeq2 ¶
IsSeq2 returns true if the passed iterator function is compatible with iter.Seq2, otherwise false.
IsSeq2 hides the Go 1.23+ specific reflect.Type.CanSeq2 behind a facade which is empty for Go versions before 1.23.
func IterKVTypes ¶
IterKVTypes returns the reflection types of an iterator's yield function's K and optional V arguments, otherwise nil K and V reflection types.
func IterateKV ¶
IterateKV loops over the key-value elements produced by an iterator function, passing the elements to the specified yield function individually and stopping only when either the iterator function runs out of elements or the yield function tell us to stop it.
IterateKV works very much like reflect.Value.Seq2 but hides the Go 1.23+ specific parts behind a facade which is empty for Go versions before 1.23, in order to simplify code maintenance for matchers when using older Go versions.
func IterateV ¶
IterateV loops over the elements produced by an iterator function, passing the elements to the specified yield function individually and stopping only when either the iterator function runs out of elements or the yield function tell us to stop it.
IterateV works very much like reflect.Value.Seq but hides the Go 1.23+ specific parts behind a facade which is empty for Go versions before 1.23, in order to simplify code maintenance for matchers when using older Go versions.
Source Files ¶
- Version
- v1.37.0 (latest)
- Published
- Apr 2, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 12 minutes ago –
Tools for package owners.