Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C++ 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.


On 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.


Ah 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.


Yeah, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: