4 ms·
Seems fairly comparable to the way it's done in C++11 lambdas.
by problems 10y ago
Seems fairly comparable to the way it's done in C++11 lambdas.
- steveklabnik 10y agoC++ lambdas and Rust closures are very similar as far as I know, the only major difference being that they use explicit capture lists and we don't.
- problems 10y agoYeah, in C++ you can sort of get away without explicit capture of all variables too by doing [=] or [&]. Though I suppose it's still explicit in a way, just saves the need to list everything.
- JoshTriplett 10y agoOn the other hand, Rust closures do compute the capture list, and then let the type system reason about the safety of those captures, which C++ lambdas (or blocks with the clang blocks extension) don't.
- problems 10y agoAh okay, so rust will only ever capture the minimal set of what's necessarily used in the lambda? Different from using [&] or similar in C++ where you capture everything.