summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorTaiki Endo <te316e89@gmail.com>2019-11-07 05:09:10 +0900
committerGitHub <noreply@github.com>2019-11-07 05:09:10 +0900
commit6f8b986bdb61843171ab90a1947349d5ac25576e (patch)
treeeca5ee41f20bedf90376da6002d435d04dd7e229 /examples
parent1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2 (diff)
chore: update futures to 0.3.0 (#1741)
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml2
-rw-r--r--examples/chat.rs4
-rw-r--r--examples/connect.rs20
3 files changed, 14 insertions, 12 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 84a546f7..782a16cb 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -9,7 +9,7 @@ tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util" }
bytes = "0.4.12"
-futures-preview = "=0.3.0-alpha.19"
+futures = "0.3.0"
[[example]]
name = "chat"
diff --git a/examples/chat.rs b/examples/chat.rs
index 0a3976d5..e0213afd 100644
--- a/examples/chat.rs
+++ b/examples/chat.rs
@@ -30,7 +30,7 @@ use tokio::net::{TcpListener, TcpStream};
use tokio::sync::{mpsc, Mutex};
use tokio_util::codec::{Framed, LinesCodec, LinesCodecError};
-use futures::{Poll, SinkExt, Stream, StreamExt};
+use futures::{SinkExt, Stream, StreamExt};
use std::collections::HashMap;
use std::env;
use std::error::Error;
@@ -38,7 +38,7 @@ use std::io;
use std::net::SocketAddr;
use std::pin::Pin;
use std::sync::Arc;
-use std::task::Context;
+use std::task::{Context, Poll};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
diff --git a/examples/connect.rs b/examples/connect.rs
index 0dd14ef2..38d81229 100644
--- a/examples/connect.rs
+++ b/examples/connect.rs
@@ -20,7 +20,7 @@ use tokio::io;
use tokio::sync::{mpsc, oneshot};
use tokio_util::codec::{FramedRead, FramedWrite};
-use futures::{SinkExt, Stream};
+use futures::{SinkExt, Stream, StreamExt};
use std::env;
use std::error::Error;
use std::net::SocketAddr;
@@ -69,7 +69,7 @@ async fn run() -> Result<(), Box<dyn Error>> {
// Temporary work around for stdin blocking the stream
fn stdin() -> impl Stream<Item = Result<Vec<u8>, io::Error>> + Unpin {
- let mut stdin = FramedRead::new(io::stdin(), codec::Bytes);
+ let mut stdin = FramedRead::new(io::stdin(), codec::Bytes).map(Ok);
let (mut tx, rx) = mpsc::unbounded_channel();
@@ -95,13 +95,15 @@ mod tcp {
let mut stream = TcpStream::connect(addr).await?;
let (r, w) = stream.split();
let sink = FramedWrite::new(w, codec::Bytes);
- let mut stream = FramedRead::new(r, codec::Bytes).filter_map(|i| match i {
- Ok(i) => future::ready(Some(i)),
- Err(e) => {
- println!("failed to read from socket; error={}", e);
- future::ready(None)
- }
- });
+ let mut stream = FramedRead::new(r, codec::Bytes)
+ .filter_map(|i| match i {
+ Ok(i) => future::ready(Some(i)),
+ Err(e) => {
+ println!("failed to read from socket; error={}", e);
+ future::ready(None)
+ }
+ })
+ .map(Ok);
match future::join(stdin.forward(sink), stdout.send_all(&mut stream)).await {
(Err(e), _) | (_, Err(e)) => Err(e.into()),