std-method

Sender::send: transfer an owned value

Sending an owned String moves it into the channel. Successful enqueue is not an acknowledgement of delivery or processing. A failed send returns the original payload inside SendError. Expected stdout (not executed): 5 Common mistake: Using a moved String after sending it.

Formal Syntax & Structure

rust syntaxrust
sender.send(value: T) -> Result<(), SendError<T>>

Working Example

Example Snippetrust
fn main() {    use std::sync::mpsc;    let (tx, rx) = mpsc::channel();    let text = String::from("draft");    tx.send(text).unwrap();    let received = rx.recv().unwrap();    println!("{}", received.len());}
Rust Reference