summaryrefslogtreecommitdiffstats
path: root/examples/connect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/connect.rs')
-rw-r--r--examples/connect.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/connect.rs b/examples/connect.rs
index 38d81229..cb003d9d 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, StreamExt};
+use futures::{Stream, StreamExt};
use std::env;
use std::error::Error;
use std::net::SocketAddr;
@@ -69,12 +69,14 @@ 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).map(Ok);
+ let mut stdin = FramedRead::new(io::stdin(), codec::Bytes);
- let (mut tx, rx) = mpsc::unbounded_channel();
+ let (tx, rx) = mpsc::unbounded_channel();
tokio::spawn(async move {
- tx.send_all(&mut stdin).await.unwrap();
+ while let Some(res) = stdin.next().await {
+ let _ = tx.send(res);
+ }
});
rx