Adds toSet to create sets from iterables (#16276)

This commit is contained in:
Jason Beetham
2020-12-14 16:20:21 -07:00
committed by GitHub
parent 38eb021f81
commit 1082d62b08
3 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
discard """
targets: "c js"
"""
import std/setutils
template main =
doAssert "abcbb".toSet == {'a', 'b', 'c'}
doAssert toSet([10u8, 12, 13]) == {10u8, 12, 13}
doAssert toSet(0u16..30) == {0u16..30}
type A = distinct char
doAssert [A('x')].toSet == {A('x')}
main()
static: main()