Skip to main content

channel

Function channel 

Source
pub fn channel<T>() -> (Sender<T>, Receiver<T>)
Expand description

Creates a one-shot channel for sending a single value between tasks.

The Sender sends the value; the Receiver awaits it.

use nuclei::sync::oneshot;

let (tx, mut rx) = oneshot::channel();
assert!(rx.try_recv().is_err());
tx.send("hello").expect("the receiver is still there");
assert_eq!(rx.try_recv(), Ok("hello"));