3 ms·
A move closure takes copies of the environment, instead of mutating the parent environment. https://doc.rust-lang.org/book/closures.html#move-closures https://
by singlow 11y ago
A move closure takes copies of the environment, instead of mutating the parent environment.
https://doc.rust-lang.org/book/closures.html#move-closures https://doc.rust-lang.org/book/closures.html#move-closures
- pdpi 11y agoIt's more accurate to say that it takes ownership of the captured environment. Whether that means copying the values or moving ownership depends on whether the values are of a type that implements Copy
- rdtsc 11y agoBut isn't it confusing that it is called "move" instead of "copy" if it takes copies?
- steveklabnik 11y agoMove and Copy are identical at the assembly level. The only difference is what you can do with the older binding. Semantically speaking, both cause a memcpy, though the optimizer may elide them. That said, you're right that saying "copy" is misleading, for this reason. But moves _are_ a kind of copy.