Skip to content

Commit

Permalink
Use .cloned() where appropriate
Browse files Browse the repository at this point in the history
Fix most of Clippy’s map_clone warnings.
  • Loading branch information
mcarton committed Jan 16, 2016
1 parent 3ed6f2c commit ebceb9b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait Registry {
impl Registry for Vec<Summary> {
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
Ok(self.iter().filter(|summary| dep.matches(*summary))
.map(|summary| summary.clone()).collect())
.cloned().collect())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
if unit.target.is_lib() && unit.profile.test {
// Libs and their tests are built in parallel, so we need to make
// sure that their metadata is different.
metadata.map(|m| m.clone()).map(|mut m| {
metadata.cloned().map(|mut m| {
m.mix(&"test");
m
})
Expand All @@ -232,7 +232,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
// file names like `target/debug/libfoo.{a,so,rlib}` and such.
None
} else {
metadata.map(|m| m.clone())
metadata.cloned()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry,
for node in r.iter().filter(|p| keep(p, to_avoid, &to_avoid_sources)) {
let deps = r.deps(node).into_iter().flat_map(|i| i)
.filter(|p| keep(p, to_avoid, &to_avoid_sources))
.map(|p| p.clone()).collect();
.cloned().collect();
registry.register_lock(node.clone(), deps);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<'cfg> Source for PathSource<'cfg> {

Ok(self.packages.iter()
.filter(|pkg| ids.iter().any(|id| pkg.package_id() == id))
.map(|pkg| pkg.clone())
.cloned()
.collect())
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ pub fn process_error(msg: &str,

ProcessError {
desc: desc,
exit: status.map(|a| a.clone()),
output: output.map(|a| a.clone()),
exit: status.cloned(),
output: output.cloned(),
cause: cause,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<N: Eq + Hash + Clone> Graph<N> {
}

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

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

0 comments on commit ebceb9b

Please sign in to comment.