diff --git a/tokio-util/src/task/join_map.rs b/tokio-util/src/task/join_map.rs index b96a3821b..e7e898fcb 100644 --- a/tokio-util/src/task/join_map.rs +++ b/tokio-util/src/task/join_map.rs @@ -69,8 +69,8 @@ use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet}; /// async fn main() { /// let mut map = JoinMap::new(); /// -/// map.spawn("hello world", async move { /* ... */ }); -/// map.spawn("goodbye world", async move { /* ... */}); +/// map.spawn("hello world", std::future::ready(1)); +/// map.spawn("goodbye world", std::future::pending()); /// /// // Look up the "goodbye world" task in the map and abort it. /// let aborted = map.abort("goodbye world"); @@ -85,7 +85,7 @@ use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet}; /// assert!(res.unwrap_err().is_cancelled()); /// } else { /// // Other tasks should complete normally. -/// assert!(res.is_ok()); +/// assert_eq!(res.unwrap(), 1); /// } /// } /// } @@ -495,12 +495,12 @@ where /// ``` /// use tokio_util::task::JoinMap; /// - /// # #[tokio::main] + /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let mut map = JoinMap::new(); /// - /// map.spawn("hello world", async move { /* ... */ }); - /// map.spawn("goodbye world", async move { /* ... */}); + /// map.spawn("hello world", std::future::ready(1)); + /// map.spawn("goodbye world", std::future::pending()); /// /// // Look up the "goodbye world" task in the map and abort it. /// map.abort("goodbye world"); @@ -511,7 +511,7 @@ where /// assert!(res.unwrap_err().is_cancelled()); /// } else { /// // Other tasks should complete normally. - /// assert!(res.is_ok()); + /// assert_eq!(res.unwrap(), 1); /// } /// } /// # }