std-method
Receiver::recv: blocking receive
Receive the next queued message, waiting if the queue is empty and a producer still exists. Once all senders are dropped and the queue is drained, return an error. Expected stdout (not executed): first true Common mistake: Waiting for another message while retaining an unused sender.
Formal Syntax & Structure
rust syntaxrust
receiver.recv() -> Result<T, RecvError>Working Example
Example Snippetrust
fn main() { use std::sync::mpsc; let (tx, rx) = mpsc::channel(); tx.send("first").unwrap(); drop(tx); println!("{}", rx.recv().unwrap()); println!("{}", rx.recv().is_err());}