From 17534cfffc72f6022d8ffd3bb0e709eba2734acc Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Sun, 22 Sep 2019 15:19:54 +0200 Subject: [PATCH] Fuse next() future --- docs/src/tutorial/handling_disconnection.md | 12 ++++++------ src/stream/stream/fuse.rs | 6 ------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/src/tutorial/handling_disconnection.md b/docs/src/tutorial/handling_disconnection.md index 21f67ab..e1eb8e9 100644 --- a/docs/src/tutorial/handling_disconnection.md +++ b/docs/src/tutorial/handling_disconnection.md @@ -94,11 +94,11 @@ async fn client_writer( let mut shutdown = shutdown.fuse(); loop { // 2 select! { - msg = messages.next() => match msg { + msg = messages.next().fuse() => match msg { Some(msg) => stream.write_all(msg.as_bytes()).await?, None => break, }, - void = shutdown.next() => match void { + void = shutdown.next().fuse() => match void { Some(void) => match void {}, // 3 None => break, } @@ -210,11 +210,11 @@ async fn client_writer( let mut shutdown = shutdown.fuse(); loop { select! { - msg = messages.next() => match msg { + msg = messages.next().fuse() => match msg { Some(msg) => stream.write_all(msg.as_bytes()).await?, None => break, }, - void = shutdown.next() => match void { + void = shutdown.next().fuse() => match void { Some(void) => match void {}, None => break, } @@ -244,11 +244,11 @@ async fn broker(events: Receiver) { let mut events = events.fuse(); loop { let event = select! { - event = events.next() => match event { + event = events.next().fuse() => match event { None => break, // 2 Some(event) => event, }, - disconnect = disconnect_receiver.next() => { + disconnect = disconnect_receiver.next().fuse() => { let (name, _pending_messages) = disconnect.unwrap(); // 3 assert!(peers.remove(&name).is_some()); continue; diff --git a/src/stream/stream/fuse.rs b/src/stream/stream/fuse.rs index 13850c5..3541937 100644 --- a/src/stream/stream/fuse.rs +++ b/src/stream/stream/fuse.rs @@ -31,9 +31,3 @@ impl futures_core::Stream for Fuse { } } } - -impl futures_core::stream::FusedStream for Fuse { - fn is_terminated(&self) -> bool { - self.done - } -}