Character range excludes its last character

ID

rust.correctness.inclusive_range_operator_complete_char

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Suspicious Construct

Language

Rust

Description

.. builds a half-open range, so this one stops one character short of the alphabet or digit span it appears to describe. Write ..= to include the final character.

Rationale

.. builds a half-open range, so this one stops one character short of the alphabet or digit span it appears to describe. Write ..= to include the final character.

The following code illustrates the pattern detected by this rule:

fn is_lowercase(c: char) -> bool {
    // FLAGGED: Character range excludes its last character
    ('a'..'z').contains(&c)
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved