▲ | shadowgovt 4 days ago | |
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. | ||
▲ | steveklabnik 4 days ago | parent [-] | |
The signature for scoped threads is both simpler and more complicated depending on how you look at it: https://doc.rust-lang.org/stable/std/thread/fn.scope.html But really, that first type signature is not very complex. It can get far, far, far worse. That’s just what happens when you encode things in types. (It reads as “spawn is a function that accepts a closure that returns a type T. It returns a JoinHandle that also wraps a T. Both the closure and the T must be able to be sent to another thread and have a static lifetime.”) |