New lint suggestion: detect HashMap/Set::iter()
followed by take_while()/skip_while()/map_while()
.
#7883
Labels
A-lint
Area: New lints
What it does
Detects usage of
HashMap/Set::iter()
(or other iterator) followed bytake_while()/skip_while()/map_while()
.Categories (optional)
suspicious
, maybecorrectness
?What is the advantage of the recommended code over the original code
iter()
inHashMap/Set
iterates in arbitrary order, and_while()
methods usually make sense where is there some kind of order in the iterator. This would catch using a e.g.HashMap
where a sorted structure would be required.Drawbacks
False positives, but it seems unlikely.
Example
Note sure if anything useful can be suggested other than detecting the issue.
The text was updated successfully, but these errors were encountered: