Skip to main content

channel

Function channel 

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

Creates a one-shot channel and answers its two halves.

The halves belong to the tasks of one shard: they are !Send.

use nuclei::sync::local::oneshot;

nuclei::runtime::block_on(async {
    let (tx, rx) = oneshot::channel();
    tx.send(3).unwrap();
    assert_eq!(rx.await, Ok(3));
});