-
Notifications
You must be signed in to change notification settings - Fork 341
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
Stream::cycle implementation #34
Stream::cycle implementation #34
Conversation
4b1c188
to
b27158c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few notes!
|
||
Ok(()) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// use async_std::stream; | ||
/// | ||
/// let mut s = stream::cycle(vec![1, 2, 3]); | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In std the API is:
let a = [1, 2, 3];
let mut it = a.iter().cycle();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&1));
I'd expect this API to be (with #125 landed):
let a = [1, 2, 3];
let mut it = a.into_stream().cycle();
assert_eq!(it.next().await, Some(&1));
assert_eq!(it.next().await, Some(&2));
assert_eq!(it.next().await, Some(&3));
assert_eq!(it.next().await, Some(&1));
assert_eq!(it.next().await, Some(&2));
assert_eq!(it.next().await, Some(&3));
assert_eq!(it.next().await, Some(&1));
Similar, but subtly different in that it's more generic, which should make it more widely applicable!
#125 has landed now which means this can be modeled after std's API. @vertexclique do you have any interest in continuing with this patch in that direction? |
It's been a while, and I'm going to assume this PR will not be continued. Thanks for the work! Going to go ahead and close this. |
stream::cycle
implementation