Replies: 1 comment
|
Seems like quite some projects are allowing this lint in specific situations: https://github.com/search?q=%2F%5C%5Ballow%28.*clippy%3A%3Aiter_nth_zero.*%29%5C%5D%2F&type=code&p=1 I don't have a strong opinion about this lint. I'd be fine with moving it to |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
.nth(0)and.next()has exactly same behavior, but clearly has different semantics in my opinion: retrieve 0-th element by advance iterator by one, and advance by one with getting current element.The lint description says
.next()is more readable but.nth(0)is more readable in some cases like example code below.Therefore, I want to discuss if
.next()is actually more readable than.nth(0)for all / most cases, and if it's not readable, I want to discuss for moving the lint to allow by default category.I think if someone knows
.nth(), it's likely to the person to know.next()and selected.nthfor some reason easons in most cases.Example code that I think intention is cleaner and more readable with
nth(0).link
All reactions