]> git.lizzy.rs Git - rust.git/blob - src/docs/cloned_instead_of_copied.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / cloned_instead_of_copied.txt
1 ### What it does
2 Checks for usages of `cloned()` on an `Iterator` or `Option` where
3 `copied()` could be used instead.
4
5 ### Why is this bad?
6 `copied()` is better because it guarantees that the type being cloned
7 implements `Copy`.
8
9 ### Example
10 ```
11 [1, 2, 3].iter().cloned();
12 ```
13 Use instead:
14 ```
15 [1, 2, 3].iter().copied();
16 ```