diff --git a/iter/gomap.go b/iter/gomap.go index e2af48a..bd53f68 100644 --- a/iter/gomap.go +++ b/iter/gomap.go @@ -25,6 +25,8 @@ func (*goMapIter[K, V]) Err() error { // FromMap produces an iterator of key-value pairs from a Go map. // The resulting iterator never returns an error. +// Note that this is implemented in terms of [FromMapKeys], +// which makes copies the keys of the map to a new slice. func FromMap[M ~map[K]V, K comparable, V any](m M) Of[Pair[K, V]] { return &goMapIter[K, V]{ m: m, @@ -33,6 +35,8 @@ func FromMap[M ~map[K]V, K comparable, V any](m M) Of[Pair[K, V]] { } // FromMapKeys produces an iterator over the keys of a Go map. +// Note that this is implemented in terms of [FromSlice], +// after first copying the keys of the map to a new slice. func FromMapKeys[M ~map[K]V, K comparable, V any](m M) Of[K] { keys := make([]K, 0, len(m)) for k := range m { diff --git a/set/set.go b/set/set.go index 5ad2f28..98ec546 100644 --- a/set/set.go +++ b/set/set.go @@ -97,6 +97,7 @@ func (s Of[T]) Eachx(f func(T) error) error { // Iter produces an iterator over the members of the set, // in an indeterminate order. // The set may be nil. +// Note that this makes a copy of the elements in the set. func (s Of[T]) Iter() iter.Of[T] { return iter.FromMapKeys(s) }