]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/implicit_clone.txt
Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726
[rust.git] / src / tools / clippy / src / docs / implicit_clone.txt
1 ### What it does
2 Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer.
3
4 ### Why is this bad?
5 These methods do the same thing as `_.clone()` but may be confusing as
6 to why we are calling `to_vec` on something that is already a `Vec` or calling `to_owned` on something that is already owned.
7
8 ### Example
9 ```
10 let a = vec![1, 2, 3];
11 let b = a.to_vec();
12 let c = a.to_owned();
13 ```
14 Use instead:
15 ```
16 let a = vec![1, 2, 3];
17 let b = a.clone();
18 let c = a.clone();
19 ```