fosskers's Blog

fosskers's Avatar Image
Haskell -> Rust -> Lisps
← All posts

Be careful about how you spawn threads in #rust



and this

tokio::spawn(async { foo().await });

Behave the same way.


This does not compile:


and this silently does nothing.

tokio::spawn(async { foo() });

In the last example, foo is dropped entirely and never ran. So if you intend to run an async function (a Future) inside a manually specified async block, make sure to await it!

To like or reply, open original post on