Trait handy_async::future::FutureExt [] [src]

pub trait FutureExt: Future + Sized {
    fn select_either<B>(self, other: B) -> SelectEither<Self, B::Future>
    where
        B: IntoFuture
, { ... } }

An extention of the Future trait.

Provided Methods

Polls both AAA and BBB, will select one which is available first.

Examples

use futures::{Future, empty, failed};
use futures::future::Either;
use handy_async::future::FutureExt;

let future = empty::<(), ()>().select_either(Ok(10) as Result<_, ()>);
if let Ok(Either::B((_, 10))) = future.wait() {
} else {
    panic!();
}

let future = failed::<(), usize>(10).select_either(empty::<(), ()>());
if let Err(Either::A((10, _))) = future.wait() {
} else {
    panic!();
}

Implementors