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

add Transform, TransformSlice functions #23

Closed shoenig closed 1 year ago

shoenig commented 1 year ago

It would be nice to be able to transform a Set of type T into another Set of type U. Ideally this could be a method on Set, but Go generics aren't able to do that (yet?), so these would need to be package level helper functions, e.g.

func Transform[A, B comparable](s *Set[A]) *Set[B]

and

func TransformSlice[A comparable, B any](s *Set[A]) []B

shoenig commented 1 year ago

Closed by #56