Fix review nits

yoshuawuyts-patch-1
Fedor Sakharov 5 years ago
parent 2384df11ed
commit 49d123c7f9
No known key found for this signature in database
GPG Key ID: 93D436E666BF0FEE

@ -57,7 +57,11 @@ pub struct RepeatWith<F, Fut, A> {
/// assert_eq!(s.next().await, None); /// assert_eq!(s.next().await, None);
/// # }) } /// # }) }
/// ``` /// ```
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A> { pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A>
where
F: FnMut() -> Fut,
Fut: Future<Output = A>,
{
RepeatWith { RepeatWith {
f: repeater, f: repeater,
future: None, future: None,
@ -79,8 +83,8 @@ where
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
loop { loop {
match self.future.is_some() { match &self.future {
true => { Some(_) => {
let res = let res =
futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx)); futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx));
@ -88,7 +92,7 @@ where
return Poll::Ready(Some(res)); return Poll::Ready(Some(res));
} }
false => { None => {
let fut = (self.as_mut().f())(); let fut = (self.as_mut().f())();
self.as_mut().future().set(Some(fut)); self.as_mut().future().set(Some(fut));

Loading…
Cancel
Save