[PATCH 4 of 5] rust: address 'error: unnecessarily eager cloning of iterator items'
Mads Kiilerich
mads at kiilerich.com
Thu Jan 11 23:59:55 UTC 2024
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1705001854 -3600
# Thu Jan 11 20:37:34 2024 +0100
# Branch stable
# Node ID f2e61759ac0e0125e275acc72bda8a00258762b9
# Parent 8e16bc622b04e2eabb3a47138aa3bdffba03e142
rust: address 'error: unnecessarily eager cloning of iterator items'
Build failed with a reference to
https://rust-lang.github.io/rust-clippy/master/index.html#iter_overeager_cloned
which seems reasonable. There doesn't seem to be any reason to not follow the advice.
diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -595,7 +595,7 @@ impl IntersectionMatcher {
std::mem::swap(&mut m1, &mut m2);
}
m1.file_set().map(|m1_files| {
- m1_files.iter().cloned().filter(|f| m2.matches(f)).collect()
+ m1_files.iter().filter(|f| m2.matches(f)).cloned().collect()
})
} else {
// without exact input file sets, we can't do an exact
@@ -688,7 +688,7 @@ impl DifferenceMatcher {
};
if base_is_exact {
new.files = base_files.map(|files| {
- files.iter().cloned().filter(|f| new.matches(f)).collect()
+ files.iter().filter(|f| new.matches(f)).cloned().collect()
});
}
new
More information about the Mercurial-devel
mailing list