How to do it...

  1. Create a Rust project to work on during this chapter with cargo new futures.
  2. Navigate into the newly-created futures folder. For the rest of this chapter, we will assume that your command line is within this directory.
  3. Inside the src folder, create a new folder called bin.
  4. Delete the generated lib.rs file, as we are not creating a library.
  5. Open the Cargo.toml file that has been generated.
  6. Under [dependencies], add the following lines:
futures = "0.2.0-beta"futures-util = "0.2.0-beta"
  1. In the src/bin folder, create a file called pool.rs.
  2. Add the following code and run it with cargo run —bin pool:
1 extern crate futures; 2 3 use futures::prelude::*; 4 use futures::task::Context; 5 use futures::channel::oneshot; 6 use futures::future::{FutureResult, ...

Get Rust Standard Library Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.