1 #[cfg(feature = "std")] main()2fn main() { 3 use std::thread; 4 use std::time::Duration; 5 6 let (sender, receiver) = oneshot::channel(); 7 let t = thread::spawn(move || { 8 thread::sleep(Duration::from_millis(2)); 9 sender.send(9u128).unwrap(); 10 }); 11 assert_eq!(receiver.recv_timeout(Duration::from_millis(100)), Ok(9)); 12 t.join().unwrap(); 13 } 14 15 #[cfg(not(feature = "std"))] main()16fn main() { 17 panic!("This example is only for when the \"sync\" feature is used"); 18 } 19