Return a Future
instead of blocking the current thread.
Use async
in front of fn
, closure
, or a block
to turn the marked code into a Future
. As such the code will not be run immediately, but will only be evaluated when the returned future is .await
ed.
We have written an async book detailing async/await and trade-offs compared to using threads.
async
is a keyword from the 2018 edition onwards.
It is available for use in stable rust from version 1.39 onwards.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/keyword.async.html