diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index d4ebad7d684..e48925b497e 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -825,17 +825,14 @@ impl Sender { /// let (tx, mut rx1) = broadcast::channel::(16); /// let mut rx2 = tx.subscribe(); /// - /// tokio::spawn(async move { - /// assert_eq!(rx1.recv().await.unwrap(), 10); - /// }); - /// /// let _ = tx.send(10); - /// assert!(tx.closed().now_or_never().is_none()); /// - /// let _ = tokio::spawn(async move { - /// assert_eq!(rx2.recv().await.unwrap(), 10); - /// }).await; + /// assert_eq!(rx1.recv().await.unwrap(), 10); + /// drop(rx1); + /// assert!(tx.closed().now_or_never().is_none()); /// + /// assert_eq!(rx2.recv().await.unwrap(), 10); + /// drop(rx2); /// assert!(tx.closed().now_or_never().is_some()); /// } /// ```