expression

Explicit biased select polling order

Biased selection polls branches in listed order. Use it when that order matters and take responsibility for starvation: a frequently ready earlier branch can delay a later one. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): first Common mistake: Using biased ordering and then assuming fair opportunities for every branch.

Formal Syntax & Structure

rust syntaxrust
tokio::select! { biased; ... }

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread", start_paused = true)]async fn main() {    let choice = tokio::select! {        biased;        _ = async {} => "first",        _ = async {} => "second",    };    println!("{choice}");}
Rust Reference