[][src]Trait pasts::prelude::Join

pub trait Join<'a, Z> {
    fn join(&'a mut self) -> Z;
}

Trait for joining a tuple of futures into a single future.

Required methods

fn join(&'a mut self) -> Z

Poll multiple futures concurrently, and return a tuple of returned values from each future.

Futures that are ready first will be executed first. This makes (a, b).join().await faster than the alternative (a.await, b.await).

#![forbid(unsafe_code)]

use pasts::prelude::*;

async fn one() -> i32 {
    42
}

async fn two() -> char {
    'a'
}

async fn example() {
    // Joined await on the two futures.
    let ret = (one(), two()).join().await;
    assert_eq!(ret, (42, 'a'));
}

pasts::ThreadInterrupt::block_on(example());
Loading content...

Implementors

Loading content...