[][src]Trait pasts::prelude::Select

pub trait Select<T, A: Future<Output = T>> {
    fn select(&mut self) -> SelectFuture<T, A>;
}

A trait to select on a slice of Futures or Option<Future>s.

Select on slice of futures.

use pasts::prelude::*;

async fn async_main() {
    let mut hello = async { "Hello" };
    let mut world = async { "World!" };
    // Hello is ready, so returns with index and result.
    assert_eq!((0, "Hello"), [hello.fut(), world.fut()].select().await);
}

pasts::ThreadInterrupt::block_on(async_main());

Required methods

fn select(&mut self) -> SelectFuture<T, A>

Poll multiple futures, and return the value from future that returns Ready first.

Loading content...

Implementations on Foreign Types

impl<T, A: Future<Output = T>> Select<T, A> for [A][src]

impl<T, A: Future<Output = T>> Select<T, A> for [Option<A>][src]

Loading content...

Implementors

Loading content...