Lots of things are not Copy/Clone where they could be (maybe?)
Closed this issue · 5 comments
Apparently, ModulesIter and co are not Copy or Clone. Is there a reason for this? So far I've just hacked around this here.
Why should they be? I can think of several reasons they should not be.
Well, I thought that since ModuleTag is literally just comprised of fields that are Copy, it could be copy too, and by extension ModulesIter. What reasons?
You should not be able to copy an iterator by accident, because you then get the same items multiple times. Imagine the following:
let skip_one_element = |iter| { iter.next() };
let iter = module_iter(…);
skip_one_element(iter);
let module = iter.next();This wouldn't work as intended, because iter is silently copied (it should be &mut iter instead).
Implementing Clone would be fine with me, because then it stays explicit.
Fair, I guess. I guess I was lucky I never ran into this...
Looks like this issue was resolved? Closing for now.