Skip to content

Commit d0c0347

Browse files
committed
feat(xmaps): add BuildSet helper to build a set from slice
1 parent be84cc8 commit d0c0347

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/xmaps/set.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package xmaps
2+
3+
// BuildSet builds a set from the given values.
4+
func BuildSet[K comparable](s ...K) map[K]struct{} {
5+
r := make(map[K]struct{}, len(s))
6+
for _, v := range s {
7+
r[v] = struct{}{}
8+
}
9+
return r
10+
}

0 commit comments

Comments
 (0)