Closed myarcana closed 1 year ago
let mut bag = HashBag::new(); bag.insert("a"); bag.insert("b"); bag.insert("b"); let bag_as_vec = bag.set_iter().collect::<Vec<(&&str, usize)>>();
Is there a way to turn bag_as_vec back into a HashBag?
bag_as_vec
HashBag
And how about for collections or iterators in general with types like Vec<T, usize> (that didn't come from HashBag::SetIter) ?
Vec<T, usize>
HashBag implements Extend<(T, usize)>, so you should be able to just:
Extend<(T, usize)>
let mut bag = HashBag::new(); bag.extend(bag_as_vec);
Is there a way to turn
bag_as_vec
back into aHashBag
?And how about for collections or iterators in general with types like
Vec<T, usize>
(that didn't come from HashBag::SetIter) ?