summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/collapsible_str_replace.txt
blob: c24c25a3028a5d5dce4806d16b028aa46125c7e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### What it does
Checks for consecutive calls to `str::replace` (2 or more)
that can be collapsed into a single call.

### Why is this bad?
Consecutive `str::replace` calls scan the string multiple times
with repetitive code.

### Example
```
let hello = "hesuo worpd"
    .replace('s', "l")
    .replace("u", "l")
    .replace('p', "l");
```
Use instead:
```
let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l");
```