The Future Trait and Async Basics

Updated

October 31, 2026

The Future Trait and Async Basics

Asynchronous Rust uses cooperative multitasking where tasks yield execution rather than blocking threads:

// The core Future trait in std
// pub trait Future {
//     type Output;
//     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
// }

async fn compute_async_val() -> u32 {
    42
}