chore: update futures to 0.3.0 (#1741)

This commit is contained in:
Taiki Endo
2019-11-07 05:09:10 +09:00
committed by GitHub
parent 1a7f6fb201
commit 6f8b986bdb
12 changed files with 31 additions and 29 deletions
+1 -1
View File
@@ -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"
+2 -2
View File
@@ -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>> {
+11 -9
View File
@@ -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()),