std-method

SyncSender::try_send: nonblocking admission

Attempt to queue a message without waiting for space. Full is temporary saturation; Disconnected means the receiving endpoint is gone. Both return the payload for an explicit policy decision. Expected stdout (not executed): busy 20 10 Common mistake: Retrying immediately in an unbounded busy loop.

Formal Syntax & Structure

rust syntaxrust
sender.try_send(value) -> Result<(), TrySendError<T>>

Working Example

Example Snippetrust
fn main() {    use std::sync::mpsc::{self, TrySendError};    let (tx, rx) = mpsc::sync_channel(1);    tx.try_send(10).unwrap();    match tx.try_send(20) { Err(TrySendError::Full(v)) => println!("busy {v}"), _ => panic!("expected full") }    println!("{}", rx.recv().unwrap());}
Rust Reference