Fuse next() future

pull/224/head
Stjepan Glavina 5 years ago
parent d55cfb1da8
commit 17534cfffc

@ -94,11 +94,11 @@ async fn client_writer(
let mut shutdown = shutdown.fuse(); let mut shutdown = shutdown.fuse();
loop { // 2 loop { // 2
select! { select! {
msg = messages.next() => match msg { msg = messages.next().fuse() => match msg {
Some(msg) => stream.write_all(msg.as_bytes()).await?, Some(msg) => stream.write_all(msg.as_bytes()).await?,
None => break, None => break,
}, },
void = shutdown.next() => match void { void = shutdown.next().fuse() => match void {
Some(void) => match void {}, // 3 Some(void) => match void {}, // 3
None => break, None => break,
} }
@ -210,11 +210,11 @@ async fn client_writer(
let mut shutdown = shutdown.fuse(); let mut shutdown = shutdown.fuse();
loop { loop {
select! { select! {
msg = messages.next() => match msg { msg = messages.next().fuse() => match msg {
Some(msg) => stream.write_all(msg.as_bytes()).await?, Some(msg) => stream.write_all(msg.as_bytes()).await?,
None => break, None => break,
}, },
void = shutdown.next() => match void { void = shutdown.next().fuse() => match void {
Some(void) => match void {}, Some(void) => match void {},
None => break, None => break,
} }
@ -244,11 +244,11 @@ async fn broker(events: Receiver<Event>) {
let mut events = events.fuse(); let mut events = events.fuse();
loop { loop {
let event = select! { let event = select! {
event = events.next() => match event { event = events.next().fuse() => match event {
None => break, // 2 None => break, // 2
Some(event) => event, Some(event) => event,
}, },
disconnect = disconnect_receiver.next() => { disconnect = disconnect_receiver.next().fuse() => {
let (name, _pending_messages) = disconnect.unwrap(); // 3 let (name, _pending_messages) = disconnect.unwrap(); // 3
assert!(peers.remove(&name).is_some()); assert!(peers.remove(&name).is_some());
continue; continue;

@ -31,9 +31,3 @@ impl<S: futures_core::Stream> futures_core::Stream for Fuse<S> {
} }
} }
} }
impl<S: futures_core::Stream> futures_core::stream::FusedStream for Fuse<S> {
fn is_terminated(&self) -> bool {
self.done
}
}

Loading…
Cancel
Save