multi: remove x/exp/maps dependency

This commit is contained in:
jike authored and jike2021 committed 2025-03-25 10:34:19 +08:00
1 parent 67d2eac437
commit e72caf7b45
7 files changed
+22 -13

No files matched your search

+3 -3
View File
@@ -2,13 +2,13 @@ package fn
import (
"fmt"
"golang.org/x/exp/maps"
"maps"
"slices"
)
// KeySet converts a map into a Set containing the keys of the map.
func KeySet[K comparable, V any](m map[K]V) Set[K] {
return NewSet(maps.Keys(m)...)
return NewSet(slices.Collect(maps.Keys(m))...)
}
// NewSubMapIntersect returns a sub-map of `m` containing only the keys found in
+5 -2
View File
@@ -1,6 +1,9 @@
package fn
import "golang.org/x/exp/maps"
import (
"maps"
"slices"
)
// Set is a generic set using type params that supports the following
// operations: diff, union, intersection, and subset.
@@ -92,7 +95,7 @@ func (s Set[T]) Equal(other Set[T]) bool {
// ToSlice returns the set as a slice.
func (s Set[T]) ToSlice() []T {
return maps.Keys(s)
return slices.Collect(maps.Keys(s))
}
// Copy copies s and returns the result.