Skip to content
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

implement DoubleEndedStream #177

Merged
merged 3 commits into from
Sep 13, 2019
Merged

implement DoubleEndedStream #177

merged 3 commits into from
Sep 13, 2019

Conversation

yoshuawuyts
Copy link
Contributor

Ref #129. This is the most basic version of the DoubleEndedStream trait. Because there is no counterpart in futures-rs we allow this to be implementable (not sure if we should though?).

This is not a high-priority trait to implement, with probably the most useful addition being the blanket impl over std::iter::Fuse (where we should have a Fuse counterpart for Stream also).

So I'm taking this one step at the time, and this PR introduces just the bare minimum to get things working. Thanks!

r? @stjepang @taiki-e

Refs

ghost
ghost previously requested changes Sep 11, 2019
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, provided we also add async fn next_back.

A natural follow-up to this PR would be an equivalent of https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.rev

By the way, I wonder -- do you perhaps have an example use case for double-ended streams?

@yoshuawuyts
Copy link
Contributor Author

yoshuawuyts commented Sep 11, 2019

By the way, I wonder -- do you perhaps have an example use case for double-ended streams?

Not anything concretely; but it generally seems like a nice thing to have.

One could imagine having a stream of tables queried from a database. In which case sometimes we want to go forward to the next page, but sometimes also backwards to the previous one (perhaps get previous ones from a local cache or something). This would allow us to express that behavior in the stream.

Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
@yoshuawuyts
Copy link
Contributor Author

Implemented the feedback and marked this API as unstable so we get some wiggle room to change things even after 1.0.

@yoshuawuyts yoshuawuyts dismissed ghost ’s stale review September 13, 2019 17:51

Feedback implemented!

@yoshuawuyts
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Sep 13, 2019
177: implement DoubleEndedStream r=yoshuawuyts a=yoshuawuyts

Ref #129. This is the most basic version of the `DoubleEndedStream` trait. Because there is no counterpart in `futures-rs` we allow this to be implementable (not sure if we should though?).

This is not a high-priority trait to implement, with probably the most useful addition being the blanket impl over [`std::iter::Fuse`](https://doc.rust-lang.org/std/iter/struct.Fuse.html) (where we should have a `Fuse` counterpart for `Stream` also).

So I'm taking this one step at the time, and this PR introduces just the bare minimum to get things working. Thanks!

r? @stjepang @taiki-e

## Refs
- https://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html
- #129 


Co-authored-by: Yoshua Wuyts <[email protected]>
@bors
Copy link
Contributor

bors bot commented Sep 13, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit fda74ac into master Sep 13, 2019
@yoshuawuyts yoshuawuyts deleted the double-ended-stream branch September 13, 2019 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant