Closed
Description
This is part of unboxed closures. cc @nikomatsakis
I suggest that we adopt the following syntax for now. We can change it and bikeshed it later.
|&: x, y| x + y // Fn
|&mut: x, y| x + y // FnMut (the commonest, eventually the default)
|: x, y| x + y // FnOnce
These create anonymous struct types that move their upvars (cf. #12831) and implement the Fn
/FnMut
/FnOnce
traits.
Per discussion last week I believe that this is necessary for 1.0. Nominating for backcompat-lang because we will remove the old closures after this is done.