summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_rem_euclid.txt
blob: d3bb8c61304e1cf513a41942d221d4e079f26171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### What it does
Checks for an expression like `((x % 4) + 4) % 4` which is a common manual reimplementation
of `x.rem_euclid(4)`.

### Why is this bad?
It's simpler and more readable.

### Example
```
let x: i32 = 24;
let rem = ((x % 4) + 4) % 4;
```
Use instead:
```
let x: i32 = 24;
let rem = x.rem_euclid(4);
```