diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-08-07 01:01:49 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-08-07 01:01:49 +0200 |
commit | ddaaca5aaad4b8841cc04875b2cd0c1ab9ec0351 (patch) | |
tree | f4136b9f93adfac661fe72cea662551ba234ee47 | |
parent | b51d5a20bcb57c058bf0f2dd2510cad645dffbf4 (diff) |
Take greater advantage of itertools
-rw-r--r-- | src/main.rs | 14 |
1 files 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<PathBuf> = 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::<Result<Vec<_>, 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 { |