Open seishun opened 2 months ago
The "environment" is a general term that here includes all the variables in the defining scope of the closure. It doesn't just mean "top-level static variables". Is that the distinction you're getting at?
I don't follow. The error message further down says "cannot move out of value
, a captured variable in an FnMut
closure". I suppose the term "environment" could include captured variables, but that's too broad: you can move a value out of the environment in an FnMut
closure as the example I provided earlier demonstrates.
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch13-01-closures.html#moving-captured-values-out-of-closures-and-the-fn-traits
Description of the problem:
The
FnMut
trait is described as follows:This conflicts with a later statement about the closure in Listing 13-8:
Moving a value out of one's body is not the same as moving a value out of the environment. For example, this works:
Suggested fix:
Ideally, make the distinction between the two clear.