hashicorp / go-set

The go-set package provides generic Set implementations for Go, including HashSet for types with a Hash() function and TreeSet for orderable data
Mozilla Public License 2.0
118 stars 8 forks source link

sets: implement .Items() for use with range keyword #82

Closed shoenig closed 2 months ago

shoenig commented 8 months ago

This PR adds a .Items() method on each of Set, HashSet, and TreeSet enabling each type to be used with the range keyword for iteration.

for element := range s.Items() {
  // ...
}

Note this is currently an experimental feature of Go 1.22 https://go.dev/wiki/RangefuncExperiment