-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Lint suggestions around vector iterations are counterproductive #3063
Comments
I personally feel that the sigils are sufficient, but don't care too strongly either way. For me, the |
I used to strongly feel in favour of sigils. Not anymore. We should probably grep around github and see how many ppl disabled the lint 😆 |
|
Oh wow I entirely forgot about this issue. Yeah if that lint is allow-by-default now, seems fine for me; I also am less opposed to these sigils now than I used to be. |
With code like
clippy complains
I think this is counter-productive. I always use
iter
,into_iter
oriter_mut
when iterating on aVec
to document whether the iterated-over variable has type&T
,T
or&mut T
, respectively. I find it much harder to see this when the indication is just a sigil in front of the vector. Essentially I use these three methods as "type ascription" whenever I am in doubt, and only dofor ... in x
when I do not really care. (I am aware that I could accidentally usex.into_iter()
on a&Vec
, and think linting against that like clippy does is a good idea -- though it should suggestx.iter()
, not&x
.)The lint website just says "readability". I wonder on which basis
for ... in &x
was deemed more readable thanfor ... in x.iter()
? I will always prefer the latter, and would even enable a lint against the former.Maybe it is just a small minority that feels like I do, but with the growing popularity of Clippy I feel we should at least have a discussion about this instead of just decreeing a certain coding style without justification. :) I am not sure what the right venue for such a discussion is, though.
As far as I am concerned, this bug would be fixed if the lint changed to allow-by-default. I might at some point send in a feature request to lint in the opposite direction. ;) Alternatively, if the majority of people agrees with the lint, then so be it -- but then at least we have had that discussion.
The text was updated successfully, but these errors were encountered: