std-module

std::sync::mpsc: message passing

An MPSC channel transfers owned messages from one or more producers to one consumer. Unlike shared mutable state, the consumer can own its processing state. The channel does not guarantee that a received message has been processed. Expected stdout (not executed): ready Common mistake: Treating a channel as shared mutable storage or a broadcast system.

Formal Syntax & Structure

rust syntaxrust
use std::sync::mpsc;

Working Example

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