add helper to iterate over elements of an addrs map

This commit is contained in:
Daniel Schmidt 2025-07-18 17:35:49 +02:00
parent 114ce5a0e2
commit 812e5a9749

View file

@ -3,6 +3,8 @@
package addrs
import "iter"
// Map represents a mapping whose keys are address types that implement
// UniqueKeyer.
//
@ -135,3 +137,13 @@ func (m Map[K, V]) Values() []V {
}
return ret
}
func (m Map[K, V]) Iter() iter.Seq2[K, V] {
return func(yield func(K, V) bool) {
for _, elem := range m.Elements() {
if !yield(elem.Key, elem.Value) {
return
}
}
}
}