Skip to content

v.checked_sub(1).unwrap_or(v) is also an implicit_saturating_sub #8215

@gilescope

Description

@gilescope

Description

we already detect saturating_subs done one way:

https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/implicit_saturating_sub.rs

I came across someone doing it another way: v.checked_sub(1).unwrap_or(v)

Thought it might be one to add into the logic. Maybe an easy one for a new person to hack on?

Version

n/a

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions