-
Notifications
You must be signed in to change notification settings - Fork 340
Add stream::Extend #211
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
Add stream::Extend #211
Conversation
Thank you for another PR! While this is a very logical addition, I'm feeling kind of unsure of the utility of this trait. The Another (minor!) concern is the name of the trait. It's a bit unfortunate that the trait name is @yoshuawuyts Do you have thoughts on this? |
It's worth noting that Rayon has In terms of uses outside of
Rayon calls their method |
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.
Added diffs to go from extend_with_stream
to stream_extend
src/stream/extend.rs
Outdated
/// | ||
/// let mut v: Vec<usize> = vec![1, 2]; | ||
/// let s = stream::repeat(3usize).take(3); | ||
/// v.extend_with_stream(s).await; |
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.
/// v.extend_with_stream(s).await; | |
/// v.stream_extend(s).await; |
src/stream/extend.rs
Outdated
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] | ||
pub trait Extend<A> { | ||
/// Extends a collection with the contents of a stream. | ||
fn extend_with_stream<'a, T: IntoStream<Item = A> + 'a>( |
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.
fn extend_with_stream<'a, T: IntoStream<Item = A> + 'a>( | |
fn stream_extend<'a, T: IntoStream<Item = A> + 'a>( |
src/stream/extend.rs
Outdated
} | ||
|
||
impl Extend<()> for () { | ||
fn extend_with_stream<'a, T: IntoStream<Item = ()> + 'a>( |
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.
fn extend_with_stream<'a, T: IntoStream<Item = ()> + 'a>( | |
fn stream_extend<'a, T: IntoStream<Item = ()> + 'a>( |
src/vec/extend.rs
Outdated
use crate::stream::{Extend, IntoStream, Stream}; | ||
|
||
impl<T> Extend<T> for Vec<T> { | ||
fn extend_with_stream<'a, S: IntoStream<Item = T> + 'a>( |
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.
fn extend_with_stream<'a, S: IntoStream<Item = T> + 'a>( | |
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>( |
Ref #129 |
56b8b8d
to
9c00d0b
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.
Looks good to me, thanks! @yoshuawuyts, can you take one final look and merge if you're happy with the PR?
@stjepang I decided to add |
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.
Excellent; thanks heaps!
Note that Should we likewise re-export our |
I think yes on the former, and no on the latter. The name conflicting only becomes a problem when wanting to implement it, which I don't think this is for (as long as we export it as |
No description provided.