Cross-posting from the URLO thread. I'm in a situation where I'd really like to be able to clone a generator or async block. Currently, it seems this isn't possible, even if the type could trivially implement clone:
let wow0 = async {};
let wow1 = Clone::clone(&wow0); // ERROR
Is there any obscure way to do this? ie. does the code for implementing Clone
for these types exist in the compiler in any shape or form but just isn't available to users without some hackery? Failing that, can we make it so that this is supported? Is this something that would require an RFC or would a PR which implements it behind a feature flag be enough?
As far as I can tell, it should be possible for any generator to implement Clone
so long as (a) all its captured variables implement Clone
, (b) all its local variables which are held across a yield
/await
implement Clone
and (c) it never holds a self-reference across a yield
/await
. Are there any other limitations I'm not seeing?