3 ms·
Note that you don't need a closure in Rust to start a thread. You can just specify a function to be called (because functions implement FnOnce).
by dthul 6y ago
Note that you don't need a closure in Rust to start a thread. You can just specify a function to be called (because functions implement FnOnce).
- scoutt 6y agoThanks. My question emerged from the fact that all the Rust threads examples I see are in the closure form || {}.
- zesterer 6y agoBecause the closure form is much more useful. You very rarely want to create a thread without first passing some state to it, and environment-passing with closures is a brilliantly ergonomic way to do this.