From 49d123c7f9b5b5a1d1e63310631dda7c57ac1100 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Sun, 6 Oct 2019 08:32:44 +0300 Subject: [PATCH] Fix review nits --- src/stream/repeat_with.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/stream/repeat_with.rs b/src/stream/repeat_with.rs index ce249dd..f38b323 100644 --- a/src/stream/repeat_with.rs +++ b/src/stream/repeat_with.rs @@ -57,7 +57,11 @@ pub struct RepeatWith { /// assert_eq!(s.next().await, None); /// # }) } /// ``` -pub fn repeat_with(repeater: F) -> RepeatWith { +pub fn repeat_with(repeater: F) -> RepeatWith +where + F: FnMut() -> Fut, + Fut: Future, +{ RepeatWith { f: repeater, future: None, @@ -79,8 +83,8 @@ where fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { loop { - match self.future.is_some() { - true => { + match &self.future { + Some(_) => { let res = futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx)); @@ -88,7 +92,7 @@ where return Poll::Ready(Some(res)); } - false => { + None => { let fut = (self.as_mut().f())(); self.as_mut().future().set(Some(fut));