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 stream::cycle(..) #388

Merged
merged 18 commits into from Nov 7, 2019
Merged

Implement stream::cycle(..) #388

merged 18 commits into from Nov 7, 2019

Conversation

felipesere
Copy link
Contributor

@felipesere felipesere commented Oct 24, 2019

This is a rough initial step that is able to take a vec and cycle it indefinitly.

I saw there were comments on #34 about the API and using IntoStream.
Would I have to impl IntoStream for a Vec<T> myself to be able to have the example be liek below?

use stream::IntoStream;

let vals = vec![1,2,3];
let s = vals.into_stream().cycle();

assert_eq!(s.next().await, Some(1));
assert_eq!(s.next().await, Some(2));
assert_eq!(s.next().await, Some(3));
assert_eq!(s.next().await, Some(1));
assert_eq!(s.next().await, Some(2));

I'm happy to get some pointers and see this through :)

Ref: #129

Copy link
Member

@k-nasa k-nasa left a comment

Choose a reason for hiding this comment

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

I'm sorry if it is an extra opinion.

src/stream/cycle.rs Outdated Show resolved Hide resolved
src/stream/cycle.rs Outdated Show resolved Hide resolved
@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Oct 28, 2019
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

Thanks so much for this patch! -- @k-nasa's feedback is on point, and some of the API would need to change before we can merge this. This is heading in the right direction though, and thanks so much for working on this!

@felipesere
Copy link
Contributor Author

@yoshuawuyts The bounds are adjusted and we take as Stream as argument.

What API changes do you have in mind? Should I attach it to stream itself so once can write

let s = stream::once(7).cycle();

src/stream/cycle.rs Outdated Show resolved Hide resolved
@yoshuawuyts
Copy link
Contributor

@felipesere yes, that's exactly what I was hoping you'd say! -- this should indeed be a method on Stream. Very excited for progress on this; we're getting real close to having all methods on Stream implemented!

@felipesere
Copy link
Contributor Author

@yoshuawuyts I've moved it, but I think clippy is unhappy on CI and not in a mood to run? 😃

src/stream/stream/cycle.rs Outdated Show resolved Hide resolved
src/stream/stream/cycle.rs Outdated Show resolved Hide resolved
@felipesere
Copy link
Contributor Author

@k-nasa @yoshuawuyts anything else to add? 😅

@felipesere
Copy link
Contributor Author

@yoshuawuyts anything I should still do on this? :)

Copy link
Contributor

@yoshuawuyts yoshuawuyts 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 great, thank you!

@yoshuawuyts yoshuawuyts merged commit d0f1996 into async-rs:master Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants