summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/collapsible_str_replace.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/collapsible_str_replace.txt')
-rw-r--r--src/tools/clippy/src/docs/collapsible_str_replace.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/collapsible_str_replace.txt b/src/tools/clippy/src/docs/collapsible_str_replace.txt
new file mode 100644
index 000000000..c24c25a30
--- /dev/null
+++ b/src/tools/clippy/src/docs/collapsible_str_replace.txt
@@ -0,0 +1,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");
+``` \ No newline at end of file