From 69dce561c831764ec77a724b0e4ce23ce46eb52b Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 20 Sep 2018 23:03:16 +0200 Subject: [PATCH] Do not clone pages in taxonomies --- components/site/src/lib.rs | 4 +--- components/taxonomies/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index efb556d1..afdf12db 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -417,9 +417,7 @@ impl Site { self.pages .values() .filter(|p| !p.is_draft()) - .cloned() - .collect::>() - .as_slice(), + .collect::>(), )?; Ok(()) diff --git a/components/taxonomies/src/lib.rs b/components/taxonomies/src/lib.rs index 2c383ab6..36dc4f2f 100644 --- a/components/taxonomies/src/lib.rs +++ b/components/taxonomies/src/lib.rs @@ -111,7 +111,7 @@ impl Taxonomy { } } -pub fn find_taxonomies(config: &Config, all_pages: &[Page]) -> Result> { +pub fn find_taxonomies(config: &Config, all_pages: Vec<&Page>) -> Result> { let taxonomies_def = { let mut m = HashMap::new(); for t in &config.taxonomies { @@ -183,9 +183,9 @@ mod tests { taxo_page3.insert("tags".to_string(), vec!["js".to_string()]); taxo_page3.insert("authors".to_string(), vec!["Vincent Prouillet".to_string()]); page3.meta.taxonomies = taxo_page3; - let pages = vec![page1, page2, page3]; + let pages = vec![&page1, &page2, &page3]; - let taxonomies = find_taxonomies(&config, &pages).unwrap(); + let taxonomies = find_taxonomies(&config, pages).unwrap(); let (tags, categories, authors) = { let mut t = None; let mut c = None; @@ -241,7 +241,7 @@ mod tests { taxo_page1.insert("tags".to_string(), vec!["rust".to_string(), "db".to_string()]); page1.meta.taxonomies = taxo_page1; - let taxonomies = find_taxonomies(&config, &vec![page1]); + let taxonomies = find_taxonomies(&config, vec![&page1]); assert!(taxonomies.is_err()); let err = taxonomies.unwrap_err(); // no path as this is created by Default