Converting a futures::Future into a std::future::Future

So I’m trying to use the nightly new fancy async and await keywords, but unfortunately there doesn’t seem to be any libraries implementing the new traits yet. So I figured I’d just use the futures@0.1 crate, and convert them to the new futures as the traits seem very similar.

So there’s only one method that the old trait should implement, and that’s ‘poll’. So I figure I should make a new struct that has a future in a field and it implements the new future trait. And then in the impl for the poll, I call the old poll and convert the results.

Does that make sense? It sounds simple enough, but I’ve found no crate or code example of someone doing this.

You will be pleased to hear that I succeeded, and I made it into a crate for you all to enjoy :wink:

https://crates.io/crates/futures_future

Maybe @alexcrichton is interested in giving feedback? :slight_smile:

3 Likes

I hear there is already a compatibility layer already from this conversation. I’m currently trying to find it but haven’t had any luck. So I’m looking forward to giving your crate a spin!

I also found that, but I think that’s a compatibility layer between 0.1 and 0.2 or something. I couldn’t find something easy to use in any case.