Skip to content

New lint suggestion: detect HashMap/Set::iter() followed by take_while()/skip_while()/map_while(). #7883

Open
@conradoplg

Description

@conradoplg

What it does

Detects usage of HashMap/Set::iter() (or other iterator) followed by take_while()/skip_while()/map_while().

Categories (optional)

  • Kind: suspicious, maybe correctness?

What is the advantage of the recommended code over the original code

iter() in HashMap/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions