blob: fcb96dcc34edf2c695ef68751e8b146c2b2908bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
### What it does
Checks for inclusive ranges where 1 is subtracted from
the upper bound, e.g., `x..=(y-1)`.
### Why is this bad?
The code is more readable with an exclusive range
like `x..y`.
### Known problems
This will cause a warning that cannot be fixed if
the consumer of the range only accepts a specific range type, instead of
the generic `RangeBounds` trait
([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)).
### Example
```
for i in x..=(y-1) {
// ..
}
```
Use instead:
```
for i in x..y {
// ..
}
```
|