Skip to content

Commit

Permalink
Apply -W clippy::cloned-instead-of-copied
Browse files Browse the repository at this point in the history
Ran `just 'clippy-flags=-W clippy::cloned-instead-of-copied' clippy-fix`

Also sorted clippy-flags
  • Loading branch information
nyurik authored and Byron committed May 26, 2023
1 parent 54d0b84 commit 150463c
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gix-odb/src/store_impls/dynamic/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ impl Store {

/// An iterator over replacements from object-ids `X` to `X-replaced` as `(X, X-replaced)`, sorted by the original id `X`.
pub fn replacements(&self) -> impl Iterator<Item = (gix_hash::ObjectId, gix_hash::ObjectId)> + '_ {
self.replacements.iter().cloned()
self.replacements.iter().copied()
}
}
2 changes: 1 addition & 1 deletion gix-odb/src/store_impls/dynamic/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ where
return match &candidates {
Some(candidates) => match candidates.len() {
0 => Ok(None),
1 => Ok(candidates.iter().cloned().next().map(Ok)),
1 => Ok(candidates.iter().copied().next().map(Ok)),
_ => Ok(Some(Err(()))),
},
None => Ok(candidate.map(Ok)),
Expand Down
2 changes: 1 addition & 1 deletion gix-odb/src/store_impls/loose/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Store {
match &mut candidates {
Some(candidates) => match candidates.len() {
0 => Ok(None),
1 => Ok(candidates.iter().next().cloned().map(Ok)),
1 => Ok(candidates.iter().next().copied().map(Ok)),
_ => Ok(Some(Err(()))),
},
None => Ok(candidate.map(Ok)),
Expand Down
2 changes: 1 addition & 1 deletion gix-packetline/src/read/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
Some(match Self::read_line_inner(reader, buf).await {
Ok(Ok(line)) => {
if delimiters.contains(&line) {
let stopped_at = delimiters.iter().find(|l| **l == line).cloned();
let stopped_at = delimiters.iter().find(|l| **l == line).copied();
buf.clear();
return (true, stopped_at, None);
} else if fail_on_err_lines {
Expand Down
2 changes: 1 addition & 1 deletion gix-packetline/src/read/blocking_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
Some(match Self::read_line_inner(reader, buf) {
Ok(Ok(line)) => {
if delimiters.contains(&line) {
let stopped_at = delimiters.iter().find(|l| **l == line).cloned();
let stopped_at = delimiters.iter().find(|l| **l == line).copied();
buf.clear();
return (true, stopped_at, None);
} else if fail_on_err_lines {
Expand Down
4 changes: 2 additions & 2 deletions gix-protocol/src/fetch/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mod arguments {
async fn include_tag() {
let mut out = Vec::new();
let mut t = transport(&mut out, true);
let mut arguments = arguments_v1(["include-tag", "feature-b"].iter().cloned());
let mut arguments = arguments_v1(["include-tag", "feature-b"].iter().copied());
assert!(arguments.can_use_include_tag());

arguments.use_include_tag();
Expand All @@ -183,7 +183,7 @@ mod arguments {
async fn haves_and_wants_for_clone() {
let mut out = Vec::new();
let mut t = transport(&mut out, true);
let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().cloned());
let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().copied());
assert!(
!arguments.can_use_include_tag(),
"needs to be enabled by features in V1"
Expand Down
2 changes: 1 addition & 1 deletion gix-transport/tests/client/blocking_io/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ Git-Protocol: version=2:value-only:key=value
drop(refs);
let res = c.invoke(
"ls-refs",
[("without-value", None), ("with-value", Some("value"))].iter().cloned(),
[("without-value", None), ("with-value", Some("value"))].iter().copied(),
Some(vec!["arg1".as_bytes().as_bstr().to_owned()].into_iter()),
)?;
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions gix-transport/tests/client/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async fn handshake_v2_and_request_inner() -> crate::Result {
"ls-refs",
[("agent", Some("git/2.28.0")), ("object-format", Some("sha1"))]
.iter()
.cloned(),
.copied(),
Some(
[
"peel",
Expand Down Expand Up @@ -364,7 +364,7 @@ async fn handshake_v2_and_request_inner() -> crate::Result {
("object-format", Some("sha1")),
]
.iter()
.cloned(),
.copied(),
Some(
[
"thin-pack",
Expand Down
8 changes: 5 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ ci-test: check doc unit-tests journey-tests-pure journey-tests-small journey-tes
# -D clippy::range-plus-one - useful, but caused too many false positives as we use range types directly quite a lot

clippy-flags := """
-D clippy::uninlined_format_args \
-D clippy::unnested-or-patterns \
-D clippy::cloned-instead-of-copied \
-D clippy::explicit-iter-loop \
-D clippy::map-unwrap-or \
-D clippy::uninlined_format_args \
-D clippy::unnested-or-patterns \
"""
# Run cargo clippy on all crates
Expand All @@ -32,12 +33,13 @@ clippy:
cargo clippy --all --no-default-features --features max-pure -- {{ clippy-flags }}
cargo clippy --all --no-default-features --features lean-async --tests -- {{ clippy-flags }}
# Run cargo clippy on all crates, fixing what can be fixed
# Run cargo clippy on all crates, fixing what can be fixed, and format all code
clippy-fix:
cargo clippy --fix --all --tests --examples -- {{ clippy-flags }}
cargo clippy --fix --allow-dirty --all --no-default-features --features small -- {{ clippy-flags }}
cargo clippy --fix --allow-dirty --all --no-default-features --features max-pure -- {{ clippy-flags }}
cargo clippy --fix --allow-dirty --all --no-default-features --features lean-async --tests -- {{ clippy-flags }}
cargo fmt --all
# Build all code in suitable configurations
check:
Expand Down

0 comments on commit 150463c

Please sign in to comment.