44 "bytes"
55 "encoding/json"
66 "iter"
7+ "maps"
78 "slices"
8-
9- "golang.org/x/exp/maps"
109)
1110
1211// A Set is an immutable collection of elements that can be of the same or different types.
@@ -42,7 +41,7 @@ func NewSet(v ...Value) Set {
4241 // Special case hashVal for empty set to 0 so that the return value of Value.hash() of Set{} and NewSet([]Value{})
4342 // are the same
4443 var hashVal uint64
45- for _ , v := range maps .Values (set ) {
44+ for v := range maps .Values (set ) {
4645 hashVal += v .hash ()
4746 }
4847
@@ -100,7 +99,7 @@ func (s Set) Slice() []Value {
10099 if s .s == nil {
101100 return nil
102101 }
103- return maps .Values (s .s )
102+ return slices . Collect ( maps .Values (s .s ) )
104103}
105104
106105// Equal returns true if the sets are Equal.
@@ -148,7 +147,7 @@ func (s *Set) UnmarshalJSON(b []byte) error {
148147func (s Set ) MarshalJSON () ([]byte , error ) {
149148 w := & bytes.Buffer {}
150149 w .WriteByte ('[' )
151- orderedKeys := maps .Keys (s .s )
150+ orderedKeys := slices . Collect ( maps .Keys (s .s ) )
152151 slices .Sort (orderedKeys )
153152 for i , k := range orderedKeys {
154153 if i != 0 {
@@ -172,7 +171,7 @@ func (s Set) String() string { return string(s.MarshalCedar()) }
172171func (s Set ) MarshalCedar () []byte {
173172 var sb bytes.Buffer
174173 sb .WriteRune ('[' )
175- orderedKeys := maps .Keys (s .s )
174+ orderedKeys := slices . Collect ( maps .Keys (s .s ) )
176175 slices .Sort (orderedKeys )
177176 for i , k := range orderedKeys {
178177 if i != 0 {
0 commit comments