Hacker News new | ask | show | jobs
by singlow 3742 days 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

2 comments

It'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
But isn't it confusing that it is called "move" instead of "copy" if it takes copies?
Move 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.