Re:Writing Pythonic Rust
by gbear605 on Monday May 24, 2021 @06:39PM
(#27270526)
Map/filter closures almost always never actually enclose variables, instead just acting on the elements from the iterator. They’re basically a one-off nameless function. On the other hand, closures used for spawning threads almost always enclose variables from the outer context. That’s an important distinction that makes them seem quite different even if they’re the same underneath.
When I started with Rust, I actually thought that the common
spawn(|| …)
syntax was something special, not just a closure with no variables.
When I started with Rust, I actually thought that the common
spawn(|| …)
syntax was something special, not just a closure with no variables.