Rust and Cargo 1 · Code patterns
Async main with Tokio
Run async code with the Tokio runtime. Add it with cargo add tokio --features full.
#[tokio::main]
async fn main() {
let body = reqwest::get("https://example.com").await.unwrap().text().await.unwrap();
println!("{body}");
}
Official Rust and Cargo 1 documentation