You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A (possibly pedantic) lint for iterating over a HashSet/HashMap would be appreciated. Given these do not stable iteration orders across program instances, any usage of them in redundant systems may cause differing results and inconsistencies. They also have an unclear iteration order (not lexicographical to keys nor by order) which may give adverse effects in a variety of other use cases.
In effect, the same as rust-lang/rust#92584 (which I would appreciate if anyone could give me insight on how to fork/run over my own project now, possibly via dylint).
Advantage
No response
Drawbacks
No response
Example
for(key, value)in my_map {}
Could be written as:
letmut keys = my_map.keys().clone().collect::<Vec<_>();
keys.sort();for key in keys {let value = &my_map[value];}
Please note I don't actually endorse the suggested alternative. My usages of map iteration frequently have context which show how iteration should occur. Without said context, my example is forced to create a slow but safe migration for this lint topic.
The text was updated successfully, but these errors were encountered:
What it does
A (possibly pedantic) lint for iterating over a HashSet/HashMap would be appreciated. Given these do not stable iteration orders across program instances, any usage of them in redundant systems may cause differing results and inconsistencies. They also have an unclear iteration order (not lexicographical to keys nor by order) which may give adverse effects in a variety of other use cases.
In effect, the same as rust-lang/rust#92584 (which I would appreciate if anyone could give me insight on how to fork/run over my own project now, possibly via dylint).
Advantage
No response
Drawbacks
No response
Example
Could be written as:
Please note I don't actually endorse the suggested alternative. My usages of map iteration frequently have context which show how iteration should occur. Without said context, my example is forced to create a slow but safe migration for this lint topic.
The text was updated successfully, but these errors were encountered: