Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast converts an element of type X to an interface of type Y.
For example, slices.Map(ks.Cast[*os.File, io.Reader], listOfFilePointers)
This appears alone because reflect is a heavy import
func Range ¶
func Range[K comparable, V any, R Rangeable[K, V]]( f func(K, V) error, r R, ) (K, error)
Range calls some function f(k, v) => err over any Rangeable of (K, V)s. If the return value of f is not nil, the iteration stops immediately, and returns (k, err) for the given k. Otherwise, returns (zero, nil).
Caution: invalid key types will panic at runtime. The key type must be int for any type other than a map. See Rangeable for details. In a channel, the key is always zero.
Types ¶
type Rangeable ¶
type Rangeable[K comparable, V any] interface { ~string | ~map[K]V | ~[]V | chan V }
Rangeable defines any type of value x where it is possible to range over using "for k, v := range x" or "v := range x" (in the case of a channel, only "v := range x" is permitted). For every Rangeable other than a map, K must always be int.