expression

Cancellation does not undo earlier effects

Dropping a future stops subsequent polling, not synchronous effects it has already performed. If partial progress matters, keep that state outside the future and design an explicit recovery policy. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 1 Common mistake: Believing the losing branch has necessarily made no changes.

Formal Syntax & Structure

rust syntaxrust
select! with a directly owned stateful future

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread", start_paused = true)]async fn main() {    use std::cell::Cell;    let count = Cell::new(0);    tokio::select! {        biased;        _ = async { count.set(1); std::future::pending::<()>().await } => unreachable!(),        _ = async {} => {},    }    println!("{}", count.get());}
Rust Reference