4 ms·
What was deprecated is the explicit closure type specification, which is only the ":" part.
by yuriks 12y ago
What was deprecated is the explicit closure type specification, which is only the ":" part.
- comex 12y agoRight. IIRC, now your choices are, roughly: |args| expr // upvars captured by reference, can't be called after function has gone out of scope move |args| expr // upvars moved from function to the closure context (or copied if trivially copyable) This is simple and good enough for most use cases. If you want more complex schemes, you have to implement them manually, e.g. to reference count the upvars, like Apple blocks do by default, wrap them in Rc and capture that. Accepting closures is a bit more complicated though.
- aturon 12y agoThat's not quite right. In the non-move case, the capture is inferred per upvar. See my other comment for details (https://news.ycombinator.com/item?id=9047766 https://news.ycombinator.com/item?id=9047766)