mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-18 18:29:44 -05:00
add helper to iterate over elements of an addrs map
This commit is contained in:
parent
114ce5a0e2
commit
812e5a9749
1 changed files with 12 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue