]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/iter_cloned_collect.txt
Rollup merge of #101014 - isikkema:fix-zmeta-stats-file-encoder-no-read-perms, r...
[rust.git] / src / tools / clippy / src / docs / iter_cloned_collect.txt
1 ### What it does
2 Checks for the use of `.cloned().collect()` on slice to
3 create a `Vec`.
4
5 ### Why is this bad?
6 `.to_vec()` is clearer
7
8 ### Example
9 ```
10 let s = [1, 2, 3, 4, 5];
11 let s2: Vec<isize> = s[..].iter().cloned().collect();
12 ```
13 The better use would be:
14 ```
15 let s = [1, 2, 3, 4, 5];
16 let s2: Vec<isize> = s.to_vec();
17 ```