From 6f8b986bdb61843171ab90a1947349d5ac25576e Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 7 Nov 2019 05:09:10 +0900 Subject: chore: update futures to 0.3.0 (#1741) --- examples/Cargo.toml | 2 +- examples/chat.rs | 4 ++-- examples/connect.rs | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'examples') 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> { 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> { // Temporary work around for stdin blocking the stream fn stdin() -> impl Stream, 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()), -- cgit v1.2.3