expression

join! waits even if a branch returns Err

join! has no special early-return behavior for Result. A returned Err is simply one of the outputs. Use this when both outcomes must be collected. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): true 9 Common mistake: Assuming one Err automatically cancels the other branch.

Formal Syntax & Structure

rust syntaxrust
tokio::join!(result_future_a, result_future_b)

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread", start_paused = true)]async fn main() {    let (a, b) = tokio::join!(async { Err::<u32, _>("failed") }, async { Ok::<_, &str>(9u32) });    println!("{} {}", a.is_err(), b.unwrap());}
Rust Reference