Repository: tokio-rs/tokio
File: tokio/src/task/join_set.rs (Rust)

Code before:
    /// this `JoinSet`, returning an [`AbortHandle`] that can be used to
    /// remotely cancel the task.
    ///
    /// [`LocalSet`]: crate::task::LocalSet
    /// [`AbortHandle`]: crate::task::AbortHandle
    #[track_caller]
    pub fn spawn_local_on<F>(&mut self, task: F, local_set: &LocalSet) -> AbortHandle
    where
        F: Future<Output = T>,
        F: 'static,
    {
        self.insert(local_set.spawn_local(task))
    }

    fn insert(&mut self, jh: JoinHandle<T>) -> AbortHandle {
        let abort = jh.abort_handle();
        let mut entry = self.inner.insert_idle(jh);

        // Set the waker that is notified when the task completes.
        entry.with_value_and_context(|jh, ctx| jh.set_join_waker(ctx.waker()));
        abort
    }

    #[doc(hidden)]
    #[deprecated(
        note = "This method is deprecated and will be removed. Use `JoinSet::join_next` instead."
    )]
    pub async fn join_one(&mut self) -> Option<Result<T, JoinError>> {
        self.join_next().await
    }

    /// Waits until one of the tasks in the set completes and returns its output.
    ///
    /// Returns `None` if the set is empty.
    ///
    /// # Cancel Safety
    ///
    /// This method is cancel safe. If `join_next` is used as the event in a `tokio::select!`
    /// statement and some other branch completes first, it is guaranteed that no tasks were
    /// removed from this `JoinSet`.
    #[doc(alias = "join_one")]
    pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
        crate::future::poll_fn(|cx| self.poll_join_next(cx))
            .await
            .map(|opt| opt.map(|(_, res)| res))
    }

    /// Waits until one of the tasks in the set completes and returns its
    /// output, along with the [task ID] of the completed task.
    ///
    /// Returns `None` if the set is empty.

Review comment (suggestion):
nit: maybe
```suggestion
        since = "1.20.0",
        note = "renamed to `JoinSet::join_next`."
```

Code after:
    /// this `JoinSet`, returning an [`AbortHandle`] that can be used to
    /// remotely cancel the task.
    ///
    /// [`LocalSet`]: crate::task::LocalSet
    /// [`AbortHandle`]: crate::task::AbortHandle
    #[track_caller]
    pub fn spawn_local_on<F>(&mut self, task: F, local_set: &LocalSet) -> AbortHandle
    where
        F: Future<Output = T>,
        F: 'static,
    {
        self.insert(local_set.spawn_local(task))
    }

    fn insert(&mut self, jh: JoinHandle<T>) -> AbortHandle {
        let abort = jh.abort_handle();
        let mut entry = self.inner.insert_idle(jh);

        // Set the waker that is notified when the task completes.
        entry.with_value_and_context(|jh, ctx| jh.set_join_waker(ctx.waker()));
        abort
    }

    #[doc(hidden)]
    #[deprecated(since = "1.20.0", note = "renamed to `JoinSet::join_next`.")]
    pub async fn join_one(&mut self) -> Option<Result<T, JoinError>> {
        self.join_next().await
    }

    /// Waits until one of the tasks in the set completes and returns its output.
    ///
    /// Returns `None` if the set is empty.
    ///
    /// # Cancel Safety
    ///
    /// This method is cancel safe. If `join_next` is used as the event in a `tokio::select!`
    /// statement and some other branch completes first, it is guaranteed that no tasks were
    /// removed from this `JoinSet`.
    #[doc(alias = "join_one")]
    pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
        crate::future::poll_fn(|cx| self.poll_join_next(cx))
            .await
            .map(|opt| opt.map(|(_, res)| res))
    }

    /// Waits until one of the tasks in the set completes and returns its
    /// output, along with the [task ID] of the completed task.
    ///
    /// Returns `None` if the set is empty.
    ///
    /// When this method returns an error, then the id of the task that failed can be accessed