From b7ff776e06073d5b4e8490c6f70bd2d7c42e18dc Mon Sep 17 00:00:00 2001 From: Manuel Thalmann <m@nuth.ch> Date: Sun, 6 Apr 2025 23:04:29 +0200 Subject: [PATCH] Wait for the tasks using `join_all` --- async-message-passing/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/async-message-passing/src/main.rs b/async-message-passing/src/main.rs index 671e08d..087b3bb 100644 --- a/async-message-passing/src/main.rs +++ b/async-message-passing/src/main.rs @@ -1,4 +1,4 @@ -use std::time::Duration; +use std::{pin::Pin, time::Duration}; fn main() { trpl::run(async { @@ -39,6 +39,9 @@ fn main() { } }; - trpl::join!(tx1_fut, tx_fut, rx_fut); + let futures: Vec<Pin<Box<dyn Future<Output = ()>>>> = + vec![Box::pin(tx1_fut), Box::pin(rx_fut), Box::pin(tx_fut)]; + + trpl::join_all(futures).await; }); }