I have have a hashset, and I want to insert all the element of the other hashset into it. How should I do it?
hash1 = hash1.union(&hash2).collect();
for element in hash2 {
hash1.insert(element)
}
Or maybe there is a better way?
I have have a hashset, and I want to insert all the element of the other hashset into it. How should I do it?
hash1 = hash1.union(&hash2).collect();
for element in hash2 {
hash1.insert(element)
}
Or maybe there is a better way?
One more option is
hash1.extend(hash2)
I looked at the doc of HashSet
but didn't noticed the Extend
trait. I was really surprised to not find something like this.