How to Run Multiple Futures Concurrently with join! and select!

Run multiple Rust futures concurrently using trpl::join to wait for all or trpl::select to handle the first completion.

Use trpl::join to wait for multiple futures to complete or trpl::select to run them concurrently and handle the first one to finish.

use std::time::Duration;

trpl::block_on(async {
    let fut_a = async { trpl::sleep(Duration::from_secs(1)).await; println!("A done"); };
    let fut_b = async { trpl::sleep(Duration::from_secs(2)).await; println!("B done"); };

    // Wait for both to finish
    trpl::join(fut_a, fut_b).await;

    // Or run concurrently and handle the first to finish
    // trpl::select(fut_a, fut_b).await;
});