From ddaaca5aaad4b8841cc04875b2cd0c1ab9ec0351 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 7 Aug 2023 01:01:49 +0200 Subject: Take greater advantage of itertools --- src/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3aa3ffa..c7ffa55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,7 @@ fn work() -> Result<(), io::Error> { let mut uniq_dsts: HashSet = HashSet::with_capacity(dsts.len()); let dir = tempdir()?; - let mut ps = srcs + let ps = srcs .iter() .zip(dsts) .map(|(s, d)| -> Result<(PathBuf, PathBuf, PathBuf), io::Error> { @@ -135,11 +135,13 @@ fn work() -> Result<(), io::Error> { Ok((s, t, d)) } }) - .collect::, io::Error>>()?; - - /* Sort the src/dst pairs so that the sources with the longest componenets - come first. */ - ps.sort_by_key(|s| Reverse(s.0.components().count())); + .map(|x| { + x.unwrap_or_else(|e| { + err!("{e}"); + }) + }) + .sorted_by_key(|s| Reverse(s.0.components().count())) + .collect_vec(); if flags.dryrun { for (s, _, d) in ps { -- cgit v1.2.3