Skip to content

Commit 909fae6

Browse files
committed
Use .cloned() where appropriate
Fix most of Clippy’s map_clone warnings.
1 parent cc0b48d commit 909fae6

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/cargo/core/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait Registry {
1515
impl Registry for Vec<Summary> {
1616
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
1717
Ok(self.iter().filter(|summary| dep.matches(*summary))
18-
.map(|summary| summary.clone()).collect())
18+
.cloned().collect())
1919
}
2020
}
2121

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
213213
if unit.target.is_lib() && unit.profile.test {
214214
// Libs and their tests are built in parallel, so we need to make
215215
// sure that their metadata is different.
216-
metadata.map(|m| m.clone()).map(|mut m| {
216+
metadata.cloned().map(|mut m| {
217217
m.mix(&"test");
218218
m
219219
})
@@ -232,7 +232,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
232232
// file names like `target/debug/libfoo.{a,so,rlib}` and such.
233233
None
234234
} else {
235-
metadata.map(|m| m.clone())
235+
metadata.cloned()
236236
}
237237
}
238238

src/cargo/ops/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry,
8989
for node in r.iter().filter(|p| keep(p, to_avoid, &to_avoid_sources)) {
9090
let deps = r.deps(node).into_iter().flat_map(|i| i)
9191
.filter(|p| keep(p, to_avoid, &to_avoid_sources))
92-
.map(|p| p.clone()).collect();
92+
.cloned().collect();
9393
registry.register_lock(node.clone(), deps);
9494
}
9595

src/cargo/sources/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'cfg> Source for PathSource<'cfg> {
312312

313313
Ok(self.packages.iter()
314314
.filter(|pkg| ids.iter().any(|id| pkg.package_id() == id))
315-
.map(|pkg| pkg.clone())
315+
.cloned()
316316
.collect())
317317
}
318318

src/cargo/util/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ pub fn process_error(msg: &str,
360360

361361
ProcessError {
362362
desc: desc,
363-
exit: status.map(|a| a.clone()),
364-
output: output.map(|a| a.clone()),
363+
exit: status.cloned(),
364+
output: output.cloned(),
365365
cause: cause,
366366
}
367367
}

src/cargo/util/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<N: Eq + Hash + Clone> Graph<N> {
2121
}
2222

2323
pub fn add(&mut self, node: N, children: &[N]) {
24-
self.nodes.insert(node, children.iter().map(|n| n.clone()).collect());
24+
self.nodes.insert(node, children.iter().cloned().collect());
2525
}
2626

2727
pub fn link(&mut self, node: N, child: N) {

0 commit comments

Comments
 (0)