From 199621b6f113f5b40220a288deaeffa191bc0ab6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 22 Oct 2023 18:39:05 -0400 Subject: [PATCH] Remove the separation of the main template. I don't think this is necessary, and it certainly isn't necessary at this level. --- src/command/build/render.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/command/build/render.rs b/src/command/build/render.rs index 0324619..3df81cc 100644 --- a/src/command/build/render.rs +++ b/src/command/build/render.rs @@ -30,21 +30,22 @@ impl SiteRenderer { pub(crate) async fn render_blog_posts(&self) -> Result<(), CustomError> { let mut renderer_integration = DusterRenderer::new(); - let (main_template, other_templates): (Vec<_>, Vec<_>) = MAIN_TEMPLATES + let sources: Vec<_> = MAIN_TEMPLATES .files() .filter(|f| f.path().extension() == Some(OsStr::new("dust"))) - .partition(|f| f.path().file_stem() == Some(OsStr::new("main"))); - if main_template.len() != 1 { + .collect(); + if sources + .iter() + .filter(|f| f.path().file_stem() == Some(OsStr::new("main"))) + .count() + != 1 + { return Err("Expect exactly 1 main.dust template file.".into()); } let decoded_templates = { - let mut decoded_templates = - Vec::with_capacity(main_template.len() + other_templates.len()); - for entry in main_template { - decoded_templates.push(build_name_contents_pairs(entry)?); - } - for entry in other_templates { + let mut decoded_templates = Vec::with_capacity(sources.len()); + for entry in sources { decoded_templates.push(build_name_contents_pairs(entry)?); } decoded_templates