Skip to content

Commit 3b6e351

Browse files
tworeccramertj
authored andcommitted
review: explicit async/await
1 parent 0a12553 commit 3b6e351

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

futures-channel/src/oneshot.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,22 @@ struct Inner<T> {
8383
/// ```
8484
/// use futures::channel::oneshot;
8585
/// use std::{thread, time::Duration};
86-
///
87-
/// fn main() {
88-
/// let (sender, receiver) = oneshot::channel::<i32>();
89-
///
90-
/// thread::spawn(|| {
91-
/// println!("THREAD: sleeping zzz...");
92-
/// thread::sleep(Duration::from_millis(2000));
93-
/// println!("THREAD: i'm awake! sending.");
94-
/// sender.send(3).unwrap();
95-
/// });
96-
///
97-
/// println!("MAIN: doing some useful stuff; and waiting...");
98-
///
99-
/// println!("MAIN: got: {:?}", futures::executor::block_on(receiver));
100-
/// }
86+
///
87+
/// let (sender, receiver) = oneshot::channel::<i32>();
88+
///
89+
/// thread::spawn(|| {
90+
/// println!("THREAD: sleeping zzz...");
91+
/// thread::sleep(Duration::from_millis(1000));
92+
/// println!("THREAD: i'm awake! sending.");
93+
/// sender.send(3).unwrap();
94+
/// });
95+
///
96+
/// println!("MAIN: doing some useful stuff");
97+
///
98+
/// futures::executor::block_on(async {
99+
/// println!("MAIN: waiting for msg...");
100+
/// println!("MAIN: got: {:?}", receiver.await)
101+
/// });
101102
/// ```
102103
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
103104
let inner = Arc::new(Inner::new());

0 commit comments

Comments
 (0)