Here is some code that works:
import sets
import sequtils
import typetraits
type
WordSet = HashSet[string]
WordList = seq[string]
const
WORDS = @["a", "b", "c", "d", "e", "a", "b", "b", "c"]
proc getWords(wordseq: WordList): WordList =
var words: WordSet
words.init()
for word in wordseq:
words.incl(word)
WordList(toSeq(words.items)) # HERE
block:
var words = getWords(WORDS)
echo words, words.type.name
However, if I add this line with the other imports:
import nre
The program won't compile any more and gives this error:
Error: undeclared field: 'items'
on the line marked HERE.
Clearly there is a name clash. But how do I avoid it so that I can use the
HashSet.items() iterator _and_ the nre's items() function?
Thanks!