mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 17:18:32 +03:00
19 lines
421 B
Plaintext
19 lines
421 B
Plaintext
### 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");
|
|
``` |