]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/string_extend_chars.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / string_extend_chars.txt
1 ### What it does
2 Checks for the use of `.extend(s.chars())` where s is a
3 `&str` or `String`.
4
5 ### Why is this bad?
6 `.push_str(s)` is clearer
7
8 ### Example
9 ```
10 let abc = "abc";
11 let def = String::from("def");
12 let mut s = String::new();
13 s.extend(abc.chars());
14 s.extend(def.chars());
15 ```
16 The correct use would be:
17 ```
18 let abc = "abc";
19 let def = String::from("def");
20 let mut s = String::new();
21 s.push_str(abc);
22 s.push_str(&def);
23 ```