▲ | pornel 4 days ago | |||||||
You know that Rust supports scoped threads? For the borrow checker, they behave like same-thread closures. Borrow checking is orthogonal to threads. You may be referring to the difficulty satisfying the 'static liftime (i.e. temporary references are not allowed when spawning a thread that may live for an arbitrarily long time). If you just spawn an independent thread, there's no guarantee that your code will reach join(), so there's no guarantee that references won't be dangling. The scoped threads API catches panics and ensures the thread will always finish before references given to it expire. | ||||||||
▲ | shadowgovt 4 days ago | parent [-] | |||||||
I'll have to look more closely at scoped threads. What I'm referring to is that compared to the relatively simple syntax of declaring scopes for arguments to functions and return values to functions, the syntax when threads get involved is (to take an example from the Rust Book, Chapter 21):
... yikes. This is getting into "As easy to read as a C++ template" territory. | ||||||||
|