(Note: I’m using myself as a case study of an experienced C programmer who’s been coming to grips with the novel aspects of Rust as a way to point out ways in which the documentation could be improved.)
After going over the reference, the guide, the API docs and blog posts, I’m still unclear about exactly what the ownership implications of
move |...| closures vs
|:|. I’m clearly missing something in the explanations; they read as if they were the same thing.
Or is it that
move means that the environment gets moved into the closure structure, and
|: | means that the closure structure is moved as
self into the closure function itself, consuming it? But I still don’t really understand what that means. Does it mean that the closure structure needs to be boxed in that case? Or is it up to
spawn (for example) to box up all the nicely self-contained state so that it can be moved to a new thread?
Are there use cases for
move |&: | /
move |&mut: |, or does
move always have to be used with
I think the docs could use one or two more clarifying examples - for example, for each type of closure, explicitly spelling out how the closure environment structure is defined, and how its passed to the corresponding closure.