channel in std::sync::oneshot - Rust
Description: Creates a new oneshot channel, returning the sender/receiver halves.

## channel

# Function channel

Source

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

🔬This is a nightly-only experimental API. (`oneshot_channel` #143674)
Expand description

Creates a new oneshot channel, returning the sender/receiver halves.

## §Examples

    #![feature(oneshot_channel)]
    use std::sync::oneshot;
    use std::thread;

    let (sender, receiver) = oneshot::channel();

    // Spawn off an expensive computation.
    thread::spawn(move || {
        sender.send(expensive_computation()).unwrap();
        // `sender` is consumed by `send`, so we cannot use it anymore.
    });

    do_other_work();

    // Let's see what that answer was...
    println!("{:?}", receiver.recv().unwrap());
    // `receiver` is consumed by `recv`, so we cannot use it anymore.