Start with the idea
A suspended async computation stores the state needed for a later poll. If that state contains an Rc or another non-Send value, the future may fail a Send bound. A non-Send temporary can still be used inside a future when it does not survive a suspension. The example places Rc in a lexical scope that ends before await and asks the compiler to verify Send on the resulting future.
Tokio spawn requires a Send + static future and a Send + static output even on a current-thread runtime. A separate local-task API supports a different contract; changing the executor’s thread count does not silently change spawn’s signature.
Keep learning, for free
The rest of this lesson is waiting for you.
Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 754 lessons and algorithm steps are included.
No payment details. Your account opens the complete Academy.