RS.CLIPPY.MANUAL_RANGE_PATTERNS
Manually writing range patterns using a combined OR pattern (`|`)
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_range_patterns. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Looks for combined OR patterns that are all contained in a specific range,
e.g. 6 | 4 | 5 | 9 | 7 | 8 can be rewritten as 4..=9.
Why is this bad?
Using an explicit range is more concise and easier to read.
Known issues
This lint intentionally does not handle numbers greater than i128::MAX for u128 literals
in order to support negative numbers.
Example
let x = 6;
let foo = matches!(x, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10);
Use instead:
let x = 6;
let foo = matches!(x, 1..=10);