]>
Commit | Line | Data |
---|---|---|
f2b60f7d FG |
1 | ### What it does |
2 | Checks for consecutive calls to `str::replace` (2 or more) | |
3 | that can be collapsed into a single call. | |
4 | ||
5 | ### Why is this bad? | |
6 | Consecutive `str::replace` calls scan the string multiple times | |
7 | with repetitive code. | |
8 | ||
9 | ### Example | |
10 | ``` | |
11 | let hello = "hesuo worpd" | |
12 | .replace('s', "l") | |
13 | .replace("u", "l") | |
14 | .replace('p', "l"); | |
15 | ``` | |
16 | Use instead: | |
17 | ``` | |
18 | let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l"); | |
19 | ``` |