Clone for closures

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.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.