std-type

SendError<T>: recover an undelivered payload

When the receiver no longer exists, sending fails and ownership of the unsent value is returned in the error. A caller may record, reroute or discard it according to its contract. Expected stdout (not executed): draft Common mistake: Discarding a valuable payload unintentionally when handling a send error.

Formal Syntax & Structure

rust syntaxrust
SendError<T>(pub T)

Working Example

Example Snippetrust
fn main() {    use std::sync::mpsc;    let (tx, rx) = mpsc::channel();    drop(rx);    let err = tx.send(String::from("draft")).unwrap_err();    println!("{}", err.0);}
Rust Reference