task: update return value of JoinSet::join_one (#4726)

This commit is contained in:
Alice Ryhl
2022-05-31 09:15:37 +02:00
committed by GitHub
parent 2bad98f879
commit 5fd1220c73
4 changed files with 44 additions and 39 deletions
+3 -5
View File
@@ -418,14 +418,12 @@ where
/// [`tokio::select!`]: tokio::select
pub async fn join_one(&mut self) -> Option<(K, Result<V, JoinError>)> {
let (res, id) = match self.tasks.join_one_with_id().await {
Ok(task) => {
let (id, output) = task?;
(Ok(output), id)
}
Err(e) => {
Some(Ok((id, output))) => (Ok(output), id),
Some(Err(e)) => {
let id = e.id();
(Err(e), id)
}
None => return None,
};
let key = self.remove_by_id(id)?;
Some((key, res))