Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix book to use futures_channel and futures_util, re-enable testing #172

Merged
merged 2 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
9 changes: 4 additions & 5 deletions docs/src/tutorial/all_together.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 8 additions & 10 deletions docs/src/tutorial/clean_shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions docs/src/tutorial/connecting_readers_and_writers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down
19 changes: 13 additions & 6 deletions docs/src/tutorial/handling_disconnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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,
};

Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorial/implementing_a_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;

Expand Down
7 changes: 4 additions & 3 deletions docs/src/tutorial/sending_messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down