From f52329ef65b96d1e5d1fd25dabd51f0fdd23ff92 Mon Sep 17 00:00:00 2001 From: Eskil Q Date: Sat, 2 Jan 2021 09:09:27 +0100 Subject: fix FromStream --- mumd/src/audio.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'mumd/src/audio.rs') diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs index 0aae1cf..afe644c 100644 --- a/mumd/src/audio.rs +++ b/mumd/src/audio.rs @@ -492,17 +492,15 @@ impl StreamingSignal for FromStream fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let s = self.get_mut(); - match s.next.take() { - Some(v) => { - match S::poll_next(Pin::new(&mut s.stream), cx) { - Poll::Ready(val) => { - s.next = val; - Poll::Ready(v) - } - Poll::Pending => Poll::Pending - } + if s.next.is_none() { + return Poll::Ready(::EQUILIBRIUM); + } + match S::poll_next(Pin::new(&mut s.stream), cx) { + Poll::Ready(val) => { + let ret = mem::replace(&mut s.next, val); + Poll::Ready(ret.unwrap()) } - None => Poll::Ready(::EQUILIBRIUM) + Poll::Pending => Poll::Pending, } } -- cgit v1.2.1