expression

Unbounded async message channel

An unbounded sender does not await queue space. A fast producer can accumulate work without a configured capacity limit. Use a bounded queue or separate admission policy when input is not strictly limited. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 6 Common mistake: Assuming unbounded means unlimited memory is available.

Formal Syntax & Structure

rust syntaxrust
tokio::sync::mpsc::unbounded_channel::<T>()

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();    for n in 1..=3 { tx.send(n).unwrap(); }    drop(tx);    let mut total = 0;    while let Some(n) = rx.recv().await { total += n; }    println!("{total}");}
Rust Reference