[][src]Trait failure_ext::FutureExt

pub trait FutureExt<F> where
    F: Future
{ fn context<D>(
        self,
        context: D
    ) -> Box<dyn Future<Item = F::Item, Error = Error>>
    where
        D: Display + Send + Sync + 'static
; }

Extension methods for trait Future.

Required methods

fn context<D>(
    self,
    context: D
) -> Box<dyn Future<Item = F::Item, Error = Error>> where
    D: Display + Send + Sync + 'static, 

Wraps the error type in a context type.

Examples

fn get_future() -> impl Future<Item = (), Error = failure::Error> {
    futures::future::err(err_msg("abcd"))
}

let x = get_future()
    .context(format!("An error occured"))
    .wait()
    .unwrap_err();

let x = format!("{}", x);
assert_eq!(x, "An error occured");
Loading content...

Implementors

impl<F> FutureExt<F> for F where
    F: Future + 'static,
    F::Error: Into<Error>, 
[src]

Loading content...