pub fn channel<T>() -> (Sender<T>, Receiver<T>)where
T: 'static + Send,
Expand description
Creates a unidirectional channel for sending objects of type T
.
Use Sender::send
and Receiver::recv
to communicate between the ends
of the channel.
Both channel endpoints are initially local to this process, but either or both endpoints may be sent to other processes via a cross-process channel that has already been established.
let (send, mut recv) = channel::<u32>();
send.send(5);
let n = recv.recv().await.unwrap();
assert_eq!(n, 5);