Skip to content

simplify AllFuture and AnyFuture #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
}
}
}