Skip to content

Commit 150463c

Browse files
nyurikByron
authored andcommitted
Apply -W clippy::cloned-instead-of-copied
Ran `just 'clippy-flags=-W clippy::cloned-instead-of-copied' clippy-fix` Also sorted clippy-flags
1 parent 54d0b84 commit 150463c

File tree

9 files changed

+15
-13
lines changed

9 files changed

+15
-13
lines changed

gix-odb/src/store_impls/dynamic/access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ impl Store {
1919

2020
/// An iterator over replacements from object-ids `X` to `X-replaced` as `(X, X-replaced)`, sorted by the original id `X`.
2121
pub fn replacements(&self) -> impl Iterator<Item = (gix_hash::ObjectId, gix_hash::ObjectId)> + '_ {
22-
self.replacements.iter().cloned()
22+
self.replacements.iter().copied()
2323
}
2424
}

gix-odb/src/store_impls/dynamic/prefix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ where
172172
return match &candidates {
173173
Some(candidates) => match candidates.len() {
174174
0 => Ok(None),
175-
1 => Ok(candidates.iter().cloned().next().map(Ok)),
175+
1 => Ok(candidates.iter().copied().next().map(Ok)),
176176
_ => Ok(Some(Err(()))),
177177
},
178178
None => Ok(candidate.map(Ok)),

gix-odb/src/store_impls/loose/find.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Store {
9494
match &mut candidates {
9595
Some(candidates) => match candidates.len() {
9696
0 => Ok(None),
97-
1 => Ok(candidates.iter().next().cloned().map(Ok)),
97+
1 => Ok(candidates.iter().next().copied().map(Ok)),
9898
_ => Ok(Some(Err(()))),
9999
},
100100
None => Ok(candidate.map(Ok)),

gix-packetline/src/read/async_io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151
Some(match Self::read_line_inner(reader, buf).await {
5252
Ok(Ok(line)) => {
5353
if delimiters.contains(&line) {
54-
let stopped_at = delimiters.iter().find(|l| **l == line).cloned();
54+
let stopped_at = delimiters.iter().find(|l| **l == line).copied();
5555
buf.clear();
5656
return (true, stopped_at, None);
5757
} else if fail_on_err_lines {

gix-packetline/src/read/blocking_io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
Some(match Self::read_line_inner(reader, buf) {
4646
Ok(Ok(line)) => {
4747
if delimiters.contains(&line) {
48-
let stopped_at = delimiters.iter().find(|l| **l == line).cloned();
48+
let stopped_at = delimiters.iter().find(|l| **l == line).copied();
4949
buf.clear();
5050
return (true, stopped_at, None);
5151
} else if fail_on_err_lines {

gix-protocol/src/fetch/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ mod arguments {
163163
async fn include_tag() {
164164
let mut out = Vec::new();
165165
let mut t = transport(&mut out, true);
166-
let mut arguments = arguments_v1(["include-tag", "feature-b"].iter().cloned());
166+
let mut arguments = arguments_v1(["include-tag", "feature-b"].iter().copied());
167167
assert!(arguments.can_use_include_tag());
168168

169169
arguments.use_include_tag();
@@ -183,7 +183,7 @@ mod arguments {
183183
async fn haves_and_wants_for_clone() {
184184
let mut out = Vec::new();
185185
let mut t = transport(&mut out, true);
186-
let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().cloned());
186+
let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().copied());
187187
assert!(
188188
!arguments.can_use_include_tag(),
189189
"needs to be enabled by features in V1"

gix-transport/tests/client/blocking_io/http/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ Git-Protocol: version=2:value-only:key=value
566566
drop(refs);
567567
let res = c.invoke(
568568
"ls-refs",
569-
[("without-value", None), ("with-value", Some("value"))].iter().cloned(),
569+
[("without-value", None), ("with-value", Some("value"))].iter().copied(),
570570
Some(vec!["arg1".as_bytes().as_bstr().to_owned()].into_iter()),
571571
)?;
572572
assert_eq!(

gix-transport/tests/client/git.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ async fn handshake_v2_and_request_inner() -> crate::Result {
325325
"ls-refs",
326326
[("agent", Some("git/2.28.0")), ("object-format", Some("sha1"))]
327327
.iter()
328-
.cloned(),
328+
.copied(),
329329
Some(
330330
[
331331
"peel",
@@ -364,7 +364,7 @@ async fn handshake_v2_and_request_inner() -> crate::Result {
364364
("object-format", Some("sha1")),
365365
]
366366
.iter()
367-
.cloned(),
367+
.copied(),
368368
Some(
369369
[
370370
"thin-pack",

justfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ ci-test: check doc unit-tests journey-tests-pure journey-tests-small journey-tes
1919
# -D clippy::range-plus-one - useful, but caused too many false positives as we use range types directly quite a lot
2020

2121
clippy-flags := """
22-
-D clippy::uninlined_format_args \
23-
-D clippy::unnested-or-patterns \
22+
-D clippy::cloned-instead-of-copied \
2423
-D clippy::explicit-iter-loop \
2524
-D clippy::map-unwrap-or \
25+
-D clippy::uninlined_format_args \
26+
-D clippy::unnested-or-patterns \
2627
"""
2728

2829
# Run cargo clippy on all crates
@@ -32,12 +33,13 @@ clippy:
3233
cargo clippy --all --no-default-features --features max-pure -- {{ clippy-flags }}
3334
cargo clippy --all --no-default-features --features lean-async --tests -- {{ clippy-flags }}
3435

35-
# Run cargo clippy on all crates, fixing what can be fixed
36+
# Run cargo clippy on all crates, fixing what can be fixed, and format all code
3637
clippy-fix:
3738
cargo clippy --fix --all --tests --examples -- {{ clippy-flags }}
3839
cargo clippy --fix --allow-dirty --all --no-default-features --features small -- {{ clippy-flags }}
3940
cargo clippy --fix --allow-dirty --all --no-default-features --features max-pure -- {{ clippy-flags }}
4041
cargo clippy --fix --allow-dirty --all --no-default-features --features lean-async --tests -- {{ clippy-flags }}
42+
cargo fmt --all
4143

4244
# Build all code in suitable configurations
4345
check:

0 commit comments

Comments
 (0)