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
commit 1082d62b08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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()