summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/suspicious_splitn.txt
blob: 79a3dbfa6f4a7371577f1b264574561ff7fd74dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for calls to [`splitn`]
(https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and
related functions with either zero or one splits.

### Why is this bad?
These calls don't actually split the value and are
likely to be intended as a different number.

### Example
```
for x in s.splitn(1, ":") {
    // ..
}
```

Use instead:
```
for x in s.splitn(2, ":") {
    // ..
}
```