2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-01 22:16:40 +00:00

refacotr: Refactor match expression

This commit is contained in:
k-nasa 2019-10-01 17:42:45 +09:00
parent 2460f35768
commit 87b272f83d
3 changed files with 11 additions and 18 deletions

View file

@ -36,12 +36,10 @@ where
let next = futures_core::ready!(self.as_mut().stream().poll_next(cx));
match next {
Some(v) => match (self.as_mut().predicate())(&v) {
true => Poll::Ready(Some(v)),
false => {
cx.waker().wake_by_ref();
Poll::Pending
}
Some(v) if (self.as_mut().predicate())(&v) => Poll::Ready(Some(v)),
Some(_) => {
cx.waker().wake_by_ref();
Poll::Pending
},
None => Poll::Ready(None),
}

View file

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

View file

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