Add explicit notion of copyability for closures. #2829
Labels
A-typesystem
Area: The type system
E-hard
Call for participation: Hard difficulty. Experience needed to fix: A lot.
Milestone
Proposal: A closure is copyable iff everything in its environment is copyable. Furthermore, non-copyable ("one-shot") closures are allowed to capture and de-initialise outer variables.
This will allow building closures that run destructors for you. It will also fix #2828.
Closures' types can then be written with copy and send traits.
fn x(f: fn()) { f(); f(); }
will no longer be legal; you have to writefn x(f: fn()<copy>)
or some-such.The text was updated successfully, but these errors were encountered: