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
pull/174/head^2
James Munns 5 years ago committed by Yoshua Wuyts
parent 7d635b3200
commit a8090be3eb

@ -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

@ -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"]

@ -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,

@ -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,

@ -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<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

@ -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<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
@ -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<T> = mpsc::UnboundedReceiver<T>;
@ -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,
};

@ -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<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

@ -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<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

Loading…
Cancel
Save