Description
There was some discussion on Discord about whether generators can be cloned. It seems to me that non-self-referential generators can be trivially cloneable if everything in their environment implements clone (including both upvars and saved state, the implementation would be non-trivial as it would have to check the current state to know which fields need cloning, but that's basically like the generated Drop
implementation).
I don't see any way that self-referential generators could be cloneable, if there were some sort of fn clone_into(&self, place: Pin<*mut Self>)
operation they could potentially support that via re-writing the self-references, but that doesn't exist yet as far as I know. You can clone them before starting by using something like impl (FnOnce() -> impl Generator) + Clone
instead of taking the generator directly.