Fuse futures in select!

This commit is contained in:
Stjepan Glavina 2019-09-22 15:35:53 +02:00
parent 17534cfffc
commit 85b80cfe9a

View file

@ -39,14 +39,14 @@ async fn try_run(addr: impl ToSocketAddrs) -> Result<()> {
let mut lines_from_stdin = BufReader::new(stdin()).lines().fuse(); // 2 let mut lines_from_stdin = BufReader::new(stdin()).lines().fuse(); // 2
loop { loop {
select! { // 3 select! { // 3
line = lines_from_server.next() => match line { line = lines_from_server.next().fuse() => match line {
Some(line) => { Some(line) => {
let line = line?; let line = line?;
println!("{}", line); println!("{}", line);
}, },
None => break, None => break,
}, },
line = lines_from_stdin.next() => match line { line = lines_from_stdin.next().fuse() => match line {
Some(line) => { Some(line) => {
let line = line?; let line = line?;
writer.write_all(line.as_bytes()).await?; writer.write_all(line.as_bytes()).await?;