Skip to content

Update futures to 0.3 #463

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

Merged
4 commits merged into from Nov 6, 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
10 changes: 3 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ broadcaster = { version = "0.2.6", optional = true, default-features = false, fe
crossbeam-channel = "0.3.9"
crossbeam-deque = "0.7.1"
crossbeam-utils = "0.6.6"
futures-core-preview = "=0.3.0-alpha.19"
futures-io-preview = "=0.3.0-alpha.19"
futures-core = "0.3.0"
futures-io = "0.3.0"
futures-timer = "1.0.2"
kv-log-macro = "1.0.4"
log = { version = "0.4.8", features = ["kv_unstable"] }
Expand All @@ -51,11 +51,7 @@ femme = "1.2.0"
rand = "0.7.2"
# surf = "1.0.2"
tempdir = "0.3.7"
futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] }

# These are used by the book for examples
futures-channel-preview = "=0.3.0-alpha.19"
futures-util-preview = "=0.3.0-alpha.19"
futures = "0.3.0"

[[test]]
name = "stream"
Expand Down
7 changes: 3 additions & 4 deletions docs/src/tutorial/all_together.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ 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_channel;
# extern crate futures_util;
# extern crate futures;
use async_std::{
io::{self, BufReader},
net::{TcpListener, TcpStream, ToSocketAddrs},
prelude::*,
task,
};
use futures_channel::mpsc;
use futures_util::SinkExt;
use futures::channel::mpsc;
use futures::SinkExt;
use std::{
collections::hash_map::{HashMap, Entry},
sync::Arc,
Expand Down
14 changes: 6 additions & 8 deletions docs/src/tutorial/clean_shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ Let's add waiting to the server:

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::{
# io::{self, BufReader},
# net::{TcpListener, TcpStream, ToSocketAddrs},
# prelude::*,
# task,
# };
# use futures_channel::mpsc;
# use futures_util::SinkExt;
# use futures::channel::mpsc;
# use futures::SinkExt;
# use std::{
# collections::hash_map::{HashMap, Entry},
# sync::Arc,
Expand Down Expand Up @@ -156,16 +155,15 @@ And to the broker:

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::{
# io::{self, BufReader},
# net::{TcpListener, TcpStream, ToSocketAddrs},
# prelude::*,
# task,
# };
# use futures_channel::mpsc;
# use futures_util::SinkExt;
# use futures::channel::mpsc;
# use futures::SinkExt;
# use std::{
# collections::hash_map::{HashMap, Entry},
# sync::Arc,
Expand Down
7 changes: 3 additions & 4 deletions docs/src/tutorial/connecting_readers_and_writers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ The order of events "Bob sends message to Alice" and "Alice joins" is determined

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::{
# net::TcpStream,
# prelude::*,
# task,
# };
# use futures_channel::mpsc;
# use futures_util::sink::SinkExt;
# use futures::channel::mpsc;
# use futures::sink::SinkExt;
# use std::sync::Arc;
#
# type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down
21 changes: 9 additions & 12 deletions docs/src/tutorial/handling_disconnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ First, let's add a shutdown channel to the `connection_loop`:

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::net::TcpStream;
# use futures_channel::mpsc;
# use futures_util::SinkExt;
# use futures::channel::mpsc;
# use futures::SinkExt;
# use std::sync::Arc;
#
# type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down Expand Up @@ -70,11 +69,10 @@ We use the `select` macro for this purpose:

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::{net::TcpStream, prelude::*};
use futures_channel::mpsc;
use futures_util::{select, FutureExt};
use futures::channel::mpsc;
use futures::{select, FutureExt};
# use std::sync::Arc;

# type Receiver<T> = mpsc::UnboundedReceiver<T>;
Expand Down Expand Up @@ -122,16 +120,15 @@ The final code looks like this:

```rust,edition2018
# extern crate async_std;
# extern crate futures_channel;
# extern crate futures_util;
# extern crate futures;
use async_std::{
io::BufReader,
net::{TcpListener, TcpStream, ToSocketAddrs},
prelude::*,
task,
};
use futures_channel::mpsc;
use futures_util::{select, FutureExt, SinkExt};
use futures::channel::mpsc;
use futures::{select, FutureExt, SinkExt};
use std::{
collections::hash_map::{Entry, HashMap},
future::Future,
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,14 +16,14 @@ With async, we can just use the `select!` macro.

```rust,edition2018
# extern crate async_std;
# extern crate futures_util;
# extern crate futures;
use async_std::{
io::{stdin, BufReader},
net::{TcpStream, ToSocketAddrs},
prelude::*,
task,
};
use futures_util::{select, FutureExt};
use futures::{select, FutureExt};

type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

Expand Down
7 changes: 3 additions & 4 deletions docs/src/tutorial/sending_messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ 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_channel;
# extern crate futures_util;
# extern crate futures;
# use async_std::{
# net::TcpStream,
# prelude::*,
# };
use futures_channel::mpsc; // 1
use futures_util::sink::SinkExt;
use futures::channel::mpsc; // 1
use futures::sink::SinkExt;
use std::sync::Arc;

# type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
Expand Down
4 changes: 2 additions & 2 deletions src/path/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,9 @@ impl Path {
/// ```no_run
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
/// #
/// use async_std::path::Path;
/// use async_std::fs;
/// use futures_util::stream::StreamExt;
/// use async_std::path::Path;
/// use async_std::prelude::*;
///
/// let path = Path::new("/laputa");
/// let mut dir = fs::read_dir(&path).await.expect("read_dir call failed");
Expand Down
6 changes: 3 additions & 3 deletions src/sync/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ impl BarrierWaitResult {

#[cfg(test)]
mod test {
use futures_channel::mpsc::unbounded;
use futures_util::sink::SinkExt;
use futures_util::stream::StreamExt;
use futures::channel::mpsc::unbounded;
use futures::sink::SinkExt;
use futures::stream::StreamExt;

use crate::sync::{Arc, Barrier};
use crate::task;
Expand Down