rustc_lint_defs::builtin

Static NON_CONTIGUOUS_RANGE_ENDPOINTS

source
pub static NON_CONTIGUOUS_RANGE_ENDPOINTS: &Lint
Expand description

The non_contiguous_range_endpoints lint detects likely off-by-one errors when using exclusive range patterns.

§Example

let x = 123u32;
match x {
    0..100 => { println!("small"); }
    101..1000 => { println!("large"); }
    _ => { println!("larger"); }
}

{{produces}}

§Explanation

It is likely a mistake to have range patterns in a match expression that miss out a single number. Check that the beginning and end values are what you expect, and keep in mind that with ..= the right bound is inclusive, and with .. it is exclusive.