Open PSeitz opened 1 year ago
Running into the same issue, what's the solution to deal with that?
IntoIterator
is implemented for &'a GroupBy<K, I, F>
(not for GroupBy<K, I, F>
) so .into_iter()
does not take ownership of GroupBy
so the iter.group_by
is dropped at the end of the function while .into_iter().flat_map()
is supposed to live longer.
We must ensure the iter.group_by()
lives at least as long as where it's used. So here I would suggest to drop the return_group_by
function and do things where it is called.
I really like
group_by
, but there is a limitation I sometimes run into, when transforming iterators, due to the temporary values. Currently that forces to consume the group_by always locally.https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=18e06b09b59c1260ba0574d48c272eff