The question came from my wrong understanding of closures. The way it is documented in the Rust book also contributed to the confusion (I am not saying the book is bad). If anyone else had this same confusion, here is what I found.
Closures do not just store the scope and run it when its called. It captures the environment in the preferred way. The environment which contains a
is stored in the closure. How the values are captured from the environment decides the trait.
The value of a
persists until the closure exists, unless some operation moves it, such as if the closure returns a
or a method consumes a
. Here, nothing moves a
out of the closure so the closure can be called as many times as I want.
A better understanding can be obtained from the FnOnce
, FnMut
, and Fn
traits. These traits are decided by how the variables are captured by the closure, not by how the variables are moved into the closure. FnMut
can be implemented on a closure where a value is move
d .