From a675cfc1f13f39607de0bdbff407a45684907729 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 5 May 2021 13:48:08 +0100 Subject: [PATCH] otterlib: Refactor shape library iteration to be less crazy These fallible iter combinators. Urgh. Signed-off-by: Ian Jackson --- src/bin/otterlib.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 3c0e371f..062ef619 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -231,25 +231,15 @@ fn main() { let tlibs = Config1::PathGlob(libs.to_owned()); load(&vec![tlibs.clone()])?; } - let mut items: Vec = - libs_list() - .into_iter() - .map(|lib| { - let contents = libs_lookup(&lib)?; - let items = opts.items - .split(SPLIT) - .map(|items| contents.list_glob(items)) - .collect::,_>>()? - .into_iter() - .flatten(); - Ok::<_,AE>((lib, items)) - }) - .collect::,_>>()? - .into_iter() - .map(|(lib, items)| { - items.into_iter().map(|item| (lib.clone(),item)).collect::>() - }).flatten() - .collect(); + let mut items: Vec = default(); + for lib in libs_list() { + let contents = libs_lookup(&lib)?; + for pat in opts.items.split(SPLIT) { + for item in contents.list_glob(pat)? { + items.push((lib.clone(), item)) + } + } + } items.sort(); match opts.outkind { -- 2.30.2