Skip to content

Improve documentation for suspicious_map #4793

Closed
@jonasbb

Description

@jonasbb

The error message for `` only mentions one possible case, that somebody confused map with `filter`.

Another likely cause is that the code predates Iterator::for_each. It was common to use count to drive the iterator to completion. It would be helpful if that case could be added to the error message, as the hit with filter confused me more than it helped.

This is the current error message of Rust stable 1.39.

error: this call to `map()` won't have an effect on the call to `count()`
    |
    | /         batches
    | |             .iter()
    | |             .map(|batch| {
    | |                 match batch {
...   |
    | |             })
    | |             .count();
    | |____________________^
    |
    = note: `-D clippy::suspicious-map` implied by `-D warnings`
    = help: make sure you did not confuse `map` with `filter`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions