Skip to content

is digits instead of digits range contains #9933

Closed
@leonardo-m

Description

@leonardo-m

What it does

It suggests to replace a coding pattern of using range + "contains" with a more specific function.

Lint Name

is_ascii_digit_instead_contains

Category

style

Advantage

Less bug-prone, shorter

Drawbacks

No response

Example

fn foo1(d: u8) -> bool {
    (b'0' ..= b'9').contains(&d)
}

Could be written as:

fn foo2(d: u8) -> bool {
    d.is_ascii_digit()
}

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsgood 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