Replies: 3 comments
-
|
hm, the markdown is being weird |
Beta Was this translation helpful? Give feedback.
-
|
While looking for a minimal example I found a seemingly obvious case where the lint doesn't trigger |
Beta Was this translation helpful? Give feedback.
-
|
Without the other context of your code, I think that the iterator variant is better. More verbose, but better. I can see already in the loop headers that we're iterating over layers and then each part of the layer. So this gives us confidence, that we won't go out of bounds for those two. This is a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I got a "needless range lint" for this code
The suggested "improvement" is this
To me at least, this makes the code much less readable. Rather than making it clear that we're iterating over every element in the support map and shattering the corrosponding part if it's not supported, it instead suggests that we add a bunch of enumerate calls which (again, to me at least) obscures the connection and makes it slightly less obvious what's going on.
Is this code really better? Can someone explain why? I don't see it but I want to find alternate viewpoints here. It feels like a blanket rule of "using iterators is always better than indexing anywhere it's possible to use them" is taking precedent over a more specific rule like "sometimes indexing two things with the same variable makes it more obvious what's going on"
Beta Was this translation helpful? Give feedback.
All reactions