std-type
TrySendError<T>: full versus disconnected
The two variants let overload handling differ from shutdown. Both contain the unsent message. Handle a full queue with a bounded policy, not indefinite immediate retry. Expected stdout (not executed): true true Common mistake: Treating a disconnected queue as a temporarily full one.
Formal Syntax & Structure
rust syntaxrust
TrySendError::Full(T); TrySendError::Disconnected(T)Working Example
Example Snippetrust
fn main() { use std::sync::mpsc::{self, TrySendError}; let (tx, rx) = mpsc::sync_channel(1); tx.try_send(1).unwrap(); println!("{}", matches!(tx.try_send(2), Err(TrySendError::Full(2)))); drop(rx); println!("{}", matches!(tx.try_send(3), Err(TrySendError::Disconnected(3))));}