-
Notifications
You must be signed in to change notification settings - Fork 13.3k
10% of calls to .*iter() are redundant #26188
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
Comments
We do already specifically talk about this in the doc, but you have to remember that Generally speaking, we accept PRs that update the code to something more idiomatic. I don't speak for everyone, but I would be 👍 on it. |
After pinging #rust-internals, it would seem that others agree. Please send a PR! Thanks :) |
Rust and Servo are bad examples for idiomatic rust code because of the hysterisis of rust upgrades. I haven't seen new code doing this, so I don't think it's a pervasive problem -- just isolated to rust. 👍 to fixing it 😄 |
The source has just over 200 calls to
iter
,iter_mut
orinto_iter
to things that take andT: IntoIterator
. This is, by my count, about 10% of them!Some examples are
left.extend(Some(x).into_iter())
instead ofleft.extend(Some(x))
andfor &(s,t) in v.iter()
instead offor &(s,t) in v
.I thought this would make a quick, trivial change to warm myself up to the build system and such, so I've already got a branch removing it. I thought I'd ask if it's actually desirable to do so, though, since it's a lot of seemingly-meaningless code churn.
If this is wanted, the docs should probably also be updated to emphasize that many calls to
.*iter()
aren't needed. Much of the documentation foriter()
and co. uses them in places where they can be elided.The text was updated successfully, but these errors were encountered: