]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/map_clone.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / map_clone.txt
1 ### What it does
2 Checks for usage of `map(|x| x.clone())` or
3 dereferencing closures for `Copy` types, on `Iterator` or `Option`,
4 and suggests `cloned()` or `copied()` instead
5
6 ### Why is this bad?
7 Readability, this can be written more concisely
8
9 ### Example
10 ```
11 let x = vec![42, 43];
12 let y = x.iter();
13 let z = y.map(|i| *i);
14 ```
15
16 The correct use would be:
17
18 ```
19 let x = vec![42, 43];
20 let y = x.iter();
21 let z = y.cloned();
22 ```