Skip to content

Commit

Permalink
simplify AllFuture and AnyFuture (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy authored and Stjepan Glavina committed Nov 21, 2019
1 parent ba1ee2d commit ec54153
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/stream/stream/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::task::{Context, Poll};
pub struct AllFuture<'a, S, F, T> {
pub(crate) stream: &'a mut S,
pub(crate) f: F,
pub(crate) result: bool,
pub(crate) _marker: PhantomData<T>,
}

Expand All @@ -19,7 +18,6 @@ impl<'a, S, F, T> AllFuture<'a, S, F, T> {
Self {
stream,
f,
result: true, // the default if the empty stream
_marker: PhantomData,
}
}
Expand All @@ -40,7 +38,6 @@ where
match next {
Some(v) => {
let result = (&mut self.f)(v);
self.result = result;

if result {
// don't forget to wake this task again to pull the next item from stream
Expand All @@ -50,7 +47,7 @@ where
Poll::Ready(false)
}
}
None => Poll::Ready(self.result),
None => Poll::Ready(true),
}
}
}
5 changes: 1 addition & 4 deletions src/stream/stream/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::task::{Context, Poll};
pub struct AnyFuture<'a, S, F, T> {
pub(crate) stream: &'a mut S,
pub(crate) f: F,
pub(crate) result: bool,
pub(crate) _marker: PhantomData<T>,
}

Expand All @@ -19,7 +18,6 @@ impl<'a, S, F, T> AnyFuture<'a, S, F, T> {
Self {
stream,
f,
result: false, // the default if the empty stream
_marker: PhantomData,
}
}
Expand All @@ -40,7 +38,6 @@ where
match next {
Some(v) => {
let result = (&mut self.f)(v);
self.result = result;

if result {
Poll::Ready(true)
Expand All @@ -50,7 +47,7 @@ where
Poll::Pending
}
}
None => Poll::Ready(self.result),
None => Poll::Ready(false),
}
}
}

0 comments on commit ec54153

Please sign in to comment.