]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/collapsible_str_replace.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / collapsible_str_replace.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for consecutive calls to `str::replace` (2 or more)
3that can be collapsed into a single call.
4
5### Why is this bad?
6Consecutive `str::replace` calls scan the string multiple times
7with repetitive code.
8
9### Example
10```
11let hello = "hesuo worpd"
12 .replace('s', "l")
13 .replace("u", "l")
14 .replace('p', "l");
15```
16Use instead:
17```
18let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l");
19```