expression
Tokio main attribute
The attribute constructs a runtime and executes the async entry point. Tokio supplies scheduling; async syntax alone supplies no runtime. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 42 Common mistake: Putting the attribute on every helper and repeatedly creating runtimes.
Formal Syntax & Structure
rust syntaxrust
#[tokio::main(flavor = "current_thread")]Working Example
Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() { let answer = async { 6 * 7 }.await; println!("{answer}");}