Adds toSet to create sets from iterables (#16276)
This commit is contained in:
parent
38eb021f81
commit
1082d62b08
3 changed files with 48 additions and 0 deletions
14
tests/stdlib/tsetutils.nim
Normal file
14
tests/stdlib/tsetutils.nim
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue