RS.CLIPPY.MANUAL_IS_ASCII_CHECK

Use dedicated method to check ascii range

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_is_ascii_check. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Suggests to use dedicated built-in methods, is_ascii_(lowercase|uppercase|digit|hexdigit) for checking on corresponding ascii range

Why is this bad?

Using the built-in functions is more readable and makes it clear that it's not a specific subset of characters, but all ASCII (lowercase|uppercase|digit|hexdigit) characters.

Example

fn main() {
    assert!(matches!(\'x\', \'a\'..=\'z\'));
    assert!(matches!(b\'X\', b\'A\'..=b\'Z\'));
    assert!(matches!(\'2\', \'0\'..=\'9\'));
    assert!(matches!(\'x\', \'A\'..=\'Z\' | \'a\'..=\'z\'));
    assert!(matches!(\'C\', \'0\'..=\'9\' | \'a\'..=\'f\' | \'A\'..=\'F\'));

    (\'0\'..=\'9\').contains(&\'0\');
    (\'a\'..=\'z\').contains(&\'a\');
    (\'A\'..=\'Z\').contains(&\'A\');
}

Use instead:

fn main() {
    assert!(\'x\'.is_ascii_lowercase());
    assert!(b\'X\'.is_ascii_uppercase());
    assert!(\'2\'.is_ascii_digit());
    assert!(\'x\'.is_ascii_alphabetic());
    assert!(\'C\'.is_ascii_hexdigit());

    \'0\'.is_ascii_digit();
    \'a\'.is_ascii_lowercase();
    \'A\'.is_ascii_uppercase();
}

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)