summaryrefslogtreecommitdiffstats
path: root/third_party/rust/oneshot-uniffi/examples/recv_ref_before_send.rs
blob: 6ed74ddfca7db38ab7221c9aff60741ac687cecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[cfg(feature = "std")]
fn main() {
    use std::thread;
    use std::time::Duration;

    let (sender, receiver) = oneshot::channel();
    let t = thread::spawn(move || {
        thread::sleep(Duration::from_millis(2));
        sender.send(9u128).unwrap();
    });
    assert_eq!(receiver.recv_ref(), Ok(9));
    t.join().unwrap();
}

#[cfg(not(feature = "std"))]
fn main() {
    panic!("This example is only for when the \"sync\" feature is used");
}