Clone for closures


#1

With unboxed closures, would there be any possiblity of deriving Clone for all closures, that only close over values that implements clone themselves?

Specifically I do not see any reason why this should not work:

fn main() {
    let k = 42i;
    let foo = |n: int| -> int n+k;
    let bar = foo.clone();
}

That would make e.g. https://stackoverflow.com/questions/21933892/clone-a-struct-storing-a-closure possible.


Cloning of closures