keyword
Rust async: create a future
An async function returns a future when called. A future describes work that can be driven to completion; calling the function alone does not run its body. Expected output (not executed): Future discarded Why: The future is dropped without being polled, so its body never prints. Common mistake: Do not assume async automatically creates a thread or starts background work.
Formal Syntax & Structure
rust syntaxrust
async fn name() -> Type { expression }Working Example
Example Snippetrust
async fn message() { println!("Inside future");}
fn main() { let pending = message(); drop(pending); println!("Future discarded");}