Skip to main content
Image
Go to rust
r/rust

"Expected lifetime parameter" with future utilizing std::error::Error

Hi,

I have an issue trying to satisfy Rust's borrow checker when dealing with futures:

extern crate futures;

use futures::Future;
use std::error::Error;

fn foo() -> impl Future<Item=(), Error=Box<Error>> {
    Ok(())
}

(https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=d5fb47ecdd85b275d786642b583c0339)

Compiler points at the Error inside Box<Error> and tells me: expected lifetime parameter, which I cannot figure out.

What's the expected lifetime parameter in this case?

Seems like it should compile without any trouble (since we're boxing the error anyway).

Thanks for any help,

Patryk.