From: Ian Jackson Date: Wed, 5 May 2021 12:48:08 +0000 (+0100) Subject: otterlib: Refactor shape library iteration to be less crazy X-Git-Tag: otter-0.6.0~376 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a675cfc1f13f39607de0bdbff407a45684907729;p=otter.git otterlib: Refactor shape library iteration to be less crazy These fallible iter combinators. Urgh. Signed-off-by: Ian Jackson --- 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 {