-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
This simple lint suggests to replace matches!() on full upper/lower case ranges with the built-in methods.
Lint Name
use_is_ascii_lower_upper_case
Category
style
Advantage
The code is simpler, it contains less tokens.
Drawbacks
None, I think.
Example
#![warn(clippy::all)]
#![warn(clippy::nursery)]
#![warn(clippy::pedantic)]
fn main() {
assert!(matches!('x', 'a' ..= 'z'));
assert!(matches!('X', 'A' ..= 'Z'));
assert!(matches!(b'x', b'a' ..= b'z'));
assert!(matches!(b'X', b'A' ..= b'Z'));
}
Could be written as:
#![warn(clippy::all)]
#![warn(clippy::nursery)]
#![warn(clippy::pedantic)]
fn main() {
assert!('x'.is_ascii_lowercase());
assert!(b'x'.is_ascii_lowercase());
assert!('X'.is_ascii_uppercase());
assert!(b'X'.is_ascii_uppercase());
}
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints