How to use tokio crate in Rust async runtime

Add the tokio crate with the rt-multi-thread feature and use the #[tokio::main] macro to run async functions.

Add tokio to your Cargo.toml with the rt-multi-thread feature and use #[tokio::main] to run your async code.

[dependencies]
tokio = { version = "1", features = ["rt-multi-thread"] }
use tokio;

#[tokio::main]
async fn main() {
    println!("Hello from async Rust!");
}