Hi, I've been trying out a minor example in Rust playgound and got stuck on
future::executors::block_on(future)
not being found. In fact it doesn't find futures::executors. Are these available in std?
I'm using Nightly channel. Thx!
P.S. I guess I am mightily confused between futures as they were outside of std - and which a lot of docs online describe - and futures as they are within std.. where's my await! macro? where's block_on?
not being found. In fact it doesn't find futures::executors . Are these available in std ?
The situation as of futures-preview 0.3-alpha.* is that std defines the Future, but no adapters. Then futures (currently futures-preview-0.3.0-alpha.18) defines all the adapters and helper functions which use std's std::futrue::Future trait.
I guess I am mightily confused between futures as they were outside of std - and which a lot of docs online describe - and futures as they are within std .
Right now, there are indeed two futures.
The futures crate is at version 0.1, and it defines the old-style futures. Most crates dealing with futures use this version in their current "released" versions, since the other kind is very new.
The second kind of future is std::future::Future, which was recently stabilized. It is accompanied by combinators and adapters from the futures-preview crate vesion 0.3-alpha.18. Git versions of tokio, hyper, etc. use this kind of future.
The futures-preview crate provides compatibility shims if you want to work with both kinds of futures - there's documentation at futures::compat - Rust. For example, you can import the Compat01As03 trait, and then use fut.compat() to turn a futures-0.1 future into a std::future::Future future.
There's several factors which I think are preventing this from working:
futures 0.3 is currently only available via the futures-preview crate, to avoid breaking the existing ecosystem.
The playground only pulls in the top 100 crates (ranked by all-time downloads) and crates that are used in the Rust Cookbook. I'm not sure if futures-preview meets this criteria.
Even if it does, both futures and futures_preview use the same crate root path (use futures) - if they were both available, how would the playground know which one you meant to import?
I think your best bet is to just use a local project, at least until 0.3 is released in the main futures package.