$cargo fmt

write-by-ref
k-nasa 5 years ago
parent c31861aa65
commit cc21bdf068

@ -37,10 +37,10 @@ where
match next { match next {
Some(v) if (self.as_mut().predicate())(&v) => Poll::Ready(Some(v)), Some(v) if (self.as_mut().predicate())(&v) => Poll::Ready(Some(v)),
Some(_) => { Some(_) => {
cx.waker().wake_by_ref(); cx.waker().wake_by_ref();
Poll::Pending Poll::Pending
}, }
None => Poll::Ready(None), None => Poll::Ready(None),
} }
} }

@ -36,11 +36,11 @@ where
let item = futures_core::ready!(Pin::new(&mut *self.stream).poll_next(cx)); let item = futures_core::ready!(Pin::new(&mut *self.stream).poll_next(cx));
match item { match item {
Some(v) if (&mut self.p)(&v) => Poll::Ready(Some(v)), Some(v) if (&mut self.p)(&v) => Poll::Ready(Some(v)),
Some(_) => { Some(_) => {
cx.waker().wake_by_ref(); cx.waker().wake_by_ref();
Poll::Pending Poll::Pending
}, }
None => Poll::Ready(None), None => Poll::Ready(None),
} }
} }

@ -38,10 +38,12 @@ where
match next { match next {
Some(v) => match self.as_mut().predicate() { Some(v) => match self.as_mut().predicate() {
Some(p) => if !p(&v) { Some(p) => {
*self.as_mut().predicate() = None; if !p(&v) {
return Poll::Ready(Some(v)); *self.as_mut().predicate() = None;
}, return Poll::Ready(Some(v));
}
}
None => return Poll::Ready(Some(v)), None => return Poll::Ready(Some(v)),
}, },
None => return Poll::Ready(None), None => return Poll::Ready(None),

@ -30,7 +30,7 @@ impl Sleepers {
pub fn wait(&self) { pub fn wait(&self) {
let mut sleep = self.sleep.lock().unwrap(); let mut sleep = self.sleep.lock().unwrap();
if !self.notified.swap(false, Ordering::SeqCst){ if !self.notified.swap(false, Ordering::SeqCst) {
*sleep += 1; *sleep += 1;
let _ = self.wake.wait(sleep).unwrap(); let _ = self.wake.wait(sleep).unwrap();
} }

Loading…
Cancel
Save