3 ms·
Forced heap allocation and GC of course that would be unacceptable in C++. IIRC Rust uses capture modifiers similar to C++.
by gpderetta 6y ago
Forced heap allocation and GC of course that would be unacceptable in C++.
IIRC Rust uses capture modifiers similar to C++.
- steveklabnik 6y agoRust is not really the same as C++ here, you get "the compiler infers how to capture things" as the default behavior, and "take everything by value", which happens with the "move" keyword. We've found that these two cases cover the vast, vast, vast majority of usage, and so C++-style specific capture modifiers aren't necessary. You can emulate C++ style stuff by taking references outside of the closure and using move to capture only the reference.