Skip to content

Incorrect documentation example for unnecessary_filter_map #4919

Closed
@lily-commure

Description

@lily-commure

The documentation for unnecessary_filter_map gives

let _ = (0..4).filter_map(i32::checked_abs);

as an example of a filter_map that can be replaced by a map. However, it is incorrect.

As can be seen from the test and its associated output, that line is actually an example of good code which should not be caught by the lint.

Probably let _ = (0..4).filter_map(|x| Some(x + 1)); would be a good example to use in the documentation instead, as it can be replaced by let _ = (0..4).map(|x| x + 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions