#Implementing FromIterator on struct
24 messages · Page 1 of 1 (latest)
You probably don't need a trait impl
oh perfect
The issue here is that you have an iterator of Dex, but are trying to make a map of (Dex, Pair). In other words, which value should be associated with each key?
oh
im trying to just have a vec of all the keys of the BTreeMap
dont need the keys
Then you want to collect in something other than a BTreeMap.
Currently, you put the result into the group variable, which means type inference figures out you want a BTreeMap, since otherwise it's a type error.
Do you want to shadow group, maybe?
let group = group.keys().cloned().collect::<Vec<_>>();
this looks like it works, ty fren
that would just override the first group var wouldnt it
Note: if you don't need the old group anymore, you can save yourself some clones with .into_keys()
oh derp
It makes it unaccessible, but it's still there technically.
This would consume it.
(it's just a method, not a trait 😄)
You would, it's just that you can write group.into_keys().collect::<Vec<_>>()
oh derp okay
Just to avoid cloning if you're not going to use group anymore anyway