-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 Iter::drain(&mut self) with feature iterator_helper #45168
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
Regarding the example: Isn't it better written: |
/// assert_eq!(6, sum); | ||
/// ``` | ||
#[inline] | ||
#[stable(feature = "iterator_helper", since = "1.22.0")] |
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.
It's a minor thing, but to keep it as predictable as possible, iter_methodname or iterator_methodname would be a good feature name. Depends on what the method name will be, of course, just change it with the method name.
This method should probably take |
/// let xs = [0, 1, 2, 3]; | ||
/// let mut sum = 0; | ||
/// | ||
/// xs.iter().map(|x| sum += x).drain(); |
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.
This is a more complex way to write xs.iter().sum()
or even xs.iter().for_each(|x| sum += x)
.
I'm not sure I understand why this needs to exist when |
Hi @dns2utf8, due to inactivity, I'm going to close this PR. Please feel free to reopen this when you have a chance to get back to it. Thank you for your contribution! ❤️ |
The doc text may be a little short