As it states, Mutex.lock returns LockResult<MutexGuard<'_, T>> and MutexGuard explicitly does not implement Send trait (!Send syntax). But why is this an issue? The reason is how Rust compiler derives whether a future is Send - the compiler currently calculates whether a future is Send based on scope information only.
Share this post
Rust: future cannot be sent between threads…
Share this post
As it states, Mutex.lock returns LockResult<MutexGuard<'_, T>> and MutexGuard explicitly does not implement Send trait (!Send syntax). But why is this an issue? The reason is how Rust compiler derives whether a future is Send - the compiler currently calculates whether a future is Send based on scope information only.