Skip to content

Commit 936a01a

Browse files
committed
feat(xmaps): add BuildSet helper to build a set from slice
1 parent 24491cf commit 936a01a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/xmaps/set.go

Lines changed: 10 additions & 0 deletions
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)