summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/needless_splitn.txt
blob: b10a84fbc42d45c806a187a8ea5ba463abc75ef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### What it does
Checks for usages of `str::splitn` (or `str::rsplitn`) where using `str::split` would be the same.
### Why is this bad?
The function `split` is simpler and there is no performance difference in these cases, considering
that both functions return a lazy iterator.
### Example
```
let str = "key=value=add";
let _ = str.splitn(3, '=').next().unwrap();
```

Use instead:
```
let str = "key=value=add";
let _ = str.split('=').next().unwrap();
```