From c334abbe5daaa101d88eb6446bdc6699c23ac302 Mon Sep 17 00:00:00 2001 From: tu6ge <772364230@qq.com> Date: Tue, 28 Jun 2022 17:33:21 +0800 Subject: [PATCH] Update multi-futures-simultaneous.md --- src/async-rust/async/multi-futures-simultaneous.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/async-rust/async/multi-futures-simultaneous.md b/src/async-rust/async/multi-futures-simultaneous.md index f54d1a91..e6aafaf0 100644 --- a/src/async-rust/async/multi-futures-simultaneous.md +++ b/src/async-rust/async/multi-futures-simultaneous.md @@ -45,6 +45,8 @@ async fn enjoy_book_and_music() -> (Book, Music) { `Duang`,目标顺利达成。同时`join!`会返回一个元组,里面的值是对应的`Future`执行结束后输出的值。 +> 如果希望同时运行一个数组里的多个异步任务,可以使用 `futures::future::join_all` 方法 + ## try_join! 由于`join!`必须等待它管理的所有 `Future` 完成后才能完成,如果你希望在某一个 `Future` 报错后就立即停止所有 `Future` 的执行,可以使用 `try_join!`,特别是当 `Future` 返回 `Result` 时: