Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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).


Thanks. My question emerged from the fact that all the Rust threads examples I see are in the closure form || {}.


Because 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: