From bda7a4965c0fb86e5412e855ee117d54c4719889 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 21 Dec 2023 12:20:11 +0100 Subject: [PATCH] src/generate.rs: some more iterator use --- src/generate.rs | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index 5a97f15a..84e6de35 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -567,30 +567,18 @@ fn configure_build( let has_build_deps = imported_build_deps.is_some() || module.build_dep_files.is_some(); // combine local build deps and imported build deps let combined_build_deps_iters = [&imported_build_deps, &module.build_dep_files]; - let combined_build_deps = { - if has_build_deps { - Some( - combined_build_deps_iters - .iter() - .flat_map(|x| x.iter()) - .flatten() - .map(|x| Cow::from(x.as_ref())) - .collect_vec(), - ) - } else { - None - } - }; + let combined_build_deps = has_build_deps.then(|| { + combined_build_deps_iters + .iter() + .flat_map(|x| x.iter()) + .flatten() + .map(|x| Cow::from(x.as_ref())) + .collect_vec() + }); - let build_deps_hash = { - if let Some(combined_build_deps) = &combined_build_deps { - let mut hasher = DefaultHasher::new(); - combined_build_deps.hash(&mut hasher); - hasher.finish() - } else { - 0 - } - }; + let build_deps_hash = combined_build_deps + .as_ref() + .map_or(0, utils::calculate_hash); if let Some(build) = &module.build { // module has custom build rule