From a8090be3eb4d9a343d5cf30b76395c76300b170d Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 10 Sep 2019 12:54:06 +0200 Subject: [PATCH] Fix book to use futures_channel and futures_util, re-enable testing (#172) * Fix book to use futures_channel and futures_util, re-enable testing * Make dev dependencies for the book explicit --- .travis.yml | 19 +++++++++---------- Cargo.toml | 4 ++++ docs/src/tutorial/all_together.md | 9 ++++----- docs/src/tutorial/clean_shutdown.md | 18 ++++++++---------- .../connecting_readers_and_writers.md | 7 ++++--- docs/src/tutorial/handling_disconnection.md | 19 +++++++++++++------ docs/src/tutorial/implementing_a_client.md | 4 ++-- docs/src/tutorial/sending_messages.md | 7 ++++--- 8 files changed, 48 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff3a53d..9664ed9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,16 +35,15 @@ matrix: script: - cargo doc --features docs - # TODO(yoshuawuyts): re-enable mdbook - # - name: book - # rust: nightly - # os: linux - # before_script: - # - test -x $HOME/.cargo/bin/mdbook || ./ci/install-mdbook.sh - # - cargo build # to find 'extern crate async_std' by `mdbook test` - # script: - # - mdbook build docs - # - mdbook test -L ./target/debug/deps docs + - name: book + rust: nightly + os: linux + before_script: + - test -x $HOME/.cargo/bin/mdbook || ./ci/install-mdbook.sh + - cargo build # to find 'extern crate async_std' by `mdbook test` + script: + - mdbook build docs + - mdbook test -L ./target/debug/deps docs script: - cargo check --features unstable --all --benches --bins --examples --tests diff --git a/Cargo.toml b/Cargo.toml index 69aa174..ca0f3fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,10 @@ femme = "1.2.0" surf = "1.0.2" tempdir = "0.3.7" +# These are used by the book for examples +futures-channel-preview = "0.3.0-alpha.18" +futures-util-preview = "0.3.0-alpha.18" + [dev-dependencies.futures-preview] version = "0.3.0-alpha.18" features = ["std", "nightly", "async-await"] diff --git a/docs/src/tutorial/all_together.md b/docs/src/tutorial/all_together.md index 415f3b8..a638e02 100644 --- a/docs/src/tutorial/all_together.md +++ b/docs/src/tutorial/all_together.md @@ -4,17 +4,16 @@ At this point, we only need to start the broker to get a fully-functioning (in t ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; use async_std::{ io::{self, BufReader}, net::{TcpListener, TcpStream, ToSocketAddrs}, prelude::*, task, }; -use futures::{ - channel::mpsc, - SinkExt, -}; +use futures_channel::mpsc; +use futures_util::SinkExt; use std::{ collections::hash_map::{HashMap, Entry}, sync::Arc, diff --git a/docs/src/tutorial/clean_shutdown.md b/docs/src/tutorial/clean_shutdown.md index 6bf7056..f61adf2 100644 --- a/docs/src/tutorial/clean_shutdown.md +++ b/docs/src/tutorial/clean_shutdown.md @@ -22,17 +22,16 @@ Let's add waiting to the server: ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::{ # io::{self, BufReader}, # net::{TcpListener, TcpStream, ToSocketAddrs}, # prelude::*, # task, # }; -# use futures::{ -# channel::mpsc, -# SinkExt, -# }; +# use futures_channel::mpsc; +# use futures_util::SinkExt; # use std::{ # collections::hash_map::{HashMap, Entry}, # sync::Arc, @@ -156,17 +155,16 @@ And to the broker: ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::{ # io::{self, BufReader}, # net::{TcpListener, TcpStream, ToSocketAddrs}, # prelude::*, # task, # }; -# use futures::{ -# channel::mpsc, -# SinkExt, -# }; +# use futures_channel::mpsc; +# use futures_util::SinkExt; # use std::{ # collections::hash_map::{HashMap, Entry}, # sync::Arc, diff --git a/docs/src/tutorial/connecting_readers_and_writers.md b/docs/src/tutorial/connecting_readers_and_writers.md index f3ccf2d..7399cec 100644 --- a/docs/src/tutorial/connecting_readers_and_writers.md +++ b/docs/src/tutorial/connecting_readers_and_writers.md @@ -12,15 +12,16 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::{ # io::{Write}, # net::TcpStream, # prelude::{Future, Stream}, # task, # }; -# use futures::channel::mpsc; -# use futures::sink::SinkExt; +# use futures_channel::mpsc; +# use futures_util::sink::SinkExt; # use std::sync::Arc; # # type Result = std::result::Result>; diff --git a/docs/src/tutorial/handling_disconnection.md b/docs/src/tutorial/handling_disconnection.md index 30827ba..351f253 100644 --- a/docs/src/tutorial/handling_disconnection.md +++ b/docs/src/tutorial/handling_disconnection.md @@ -19,9 +19,11 @@ First, let's add a shutdown channel to the `client`: ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::net::TcpStream; -# use futures::{channel::mpsc, SinkExt}; +# use futures_channel::mpsc; +# use futures_util::SinkExt; # use std::sync::Arc; # # type Result = std::result::Result>; @@ -68,9 +70,11 @@ We use the `select` macro for this purpose: ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::{io::Write, net::TcpStream}; -use futures::{channel::mpsc, select, FutureExt, StreamExt}; +use futures_channel::mpsc; +use futures_util::{select, FutureExt, StreamExt}; # use std::sync::Arc; # type Receiver = mpsc::UnboundedReceiver; @@ -118,15 +122,18 @@ The final code looks like this: ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; use async_std::{ io::{BufReader, BufRead, Write}, net::{TcpListener, TcpStream, ToSocketAddrs}, task, }; -use futures::{channel::mpsc, future::Future, select, FutureExt, SinkExt, StreamExt}; +use futures_channel::mpsc; +use futures_util::{select, FutureExt, SinkExt, StreamExt}; use std::{ collections::hash_map::{Entry, HashMap}, + future::Future, sync::Arc, }; diff --git a/docs/src/tutorial/implementing_a_client.md b/docs/src/tutorial/implementing_a_client.md index 97e7319..a3ba93a 100644 --- a/docs/src/tutorial/implementing_a_client.md +++ b/docs/src/tutorial/implementing_a_client.md @@ -16,13 +16,13 @@ With async, we can just use the `select!` macro. ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_util; use async_std::{ io::{stdin, BufRead, BufReader, Write}, net::{TcpStream, ToSocketAddrs}, task, }; -use futures::{select, FutureExt, StreamExt}; +use futures_util::{select, FutureExt, StreamExt}; type Result = std::result::Result>; diff --git a/docs/src/tutorial/sending_messages.md b/docs/src/tutorial/sending_messages.md index 80784c2..6fec8c9 100644 --- a/docs/src/tutorial/sending_messages.md +++ b/docs/src/tutorial/sending_messages.md @@ -13,14 +13,15 @@ if Alice and Charley send two messages to Bob at the same time, Bob will see the ```rust,edition2018 # extern crate async_std; -# extern crate futures; +# extern crate futures_channel; +# extern crate futures_util; # use async_std::{ # io::Write, # net::TcpStream, # prelude::Stream, # }; -use futures::channel::mpsc; // 1 -use futures::sink::SinkExt; +use futures_channel::mpsc; // 1 +use futures_util::sink::SinkExt; use std::sync::Arc; # type Result = std::result::Result>;