From a9da220923bbd329e367ac31de229cc56d470b8d Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Mon, 26 Oct 2020 11:44:46 +0100 Subject: oneshot: update closed() docs to use tokio::select! (#3050) --- tokio/src/sync/oneshot.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tokio/src/sync/oneshot.rs') diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs index 951ab71d..e0a9e793 100644 --- a/tokio/src/sync/oneshot.rs +++ b/tokio/src/sync/oneshot.rs @@ -285,8 +285,6 @@ impl Sender { /// use tokio::sync::oneshot; /// use tokio::time::{self, Duration}; /// - /// use futures::{select, FutureExt}; - /// /// async fn compute() -> String { /// // Complex computation returning a `String` /// # "hello".to_string() @@ -297,12 +295,14 @@ impl Sender { /// let (mut tx, rx) = oneshot::channel(); /// /// tokio::spawn(async move { - /// select! { - /// _ = tx.closed().fuse() => { + /// tokio::select! { + /// _ = tx.closed() => { /// // The receiver dropped, no need to do any further work /// } - /// value = compute().fuse() => { - /// tx.send(value).unwrap() + /// value = compute() => { + /// // The send can fail if the channel was closed at the exact same + /// // time as when compute() finished, so just ignore the failure. + /// let _ = tx.send(value); /// } /// } /// }); -- cgit v1.2.3