Skip to content

Commit 2d99354

Browse files
committed
Prefer slice patterns over length check and indexing
1 parent a9b0e56 commit 2d99354

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

collector/src/bin/collector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,10 +1158,10 @@ fn main_result() -> anyhow::Result<i32> {
11581158
scenarios,
11591159
&mut errors,
11601160
);
1161-
if diffs.len() == 1 {
1161+
if let [diff] = &diffs[..] {
11621162
let short = out_dir.join("cgann-diff-latest");
1163-
std::fs::copy(&diffs[0], &short).expect("copy to short path");
1164-
eprintln!("Original diff at: {}", diffs[0].to_string_lossy());
1163+
std::fs::copy(diff, &short).expect("copy to short path");
1164+
eprintln!("Original diff at: {}", diff.to_string_lossy());
11651165
eprintln!("Short path: {}", short.to_string_lossy());
11661166
} else {
11671167
eprintln!("Diffs:");

collector/src/compare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub async fn compare_artifacts(
8080
None => select_artifact_id("base", &aids)?.to_string(),
8181
};
8282
aids.retain(|id| id != &base);
83-
let modified = if aids.len() == 1 {
84-
let new_modified = aids[0].clone();
83+
let modified = if let [new_modified] = &aids[..] {
84+
let new_modified = new_modified.clone();
8585
println!(
8686
"Only 1 artifact remains, automatically selecting: {}",
8787
new_modified

0 commit comments

Comments
 (0)