From cd70aac0651cf49f7c1a6cc64067537f789fdeba Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sun, 19 Mar 2017 19:29:43 +0900 Subject: [PATCH] Clippy run --- src/page.rs | 2 +- src/site.rs | 6 +++--- tests/site.rs | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/page.rs b/src/page.rs index 6b2e69c4..6ff93766 100644 --- a/src/page.rs +++ b/src/page.rs @@ -187,7 +187,7 @@ impl Page { let path = path.as_ref(); let content = read_file(path)?; let mut page = Page::parse(path, &content, config)?; - page.assets = find_related_assets(&path.parent().unwrap()); + page.assets = find_related_assets(path.parent().unwrap()); if !page.assets.is_empty() && page.file_name != "index" { bail!("Page `{}` has assets but is not named index.md", path.display()); diff --git a/src/site.rs b/src/site.rs index 2e9bd178..48793672 100644 --- a/src/site.rs +++ b/src/site.rs @@ -74,7 +74,7 @@ impl Site { let mut site = Site { base_path: path.to_path_buf(), - config: get_config(&path), + config: get_config(path), pages: HashMap::new(), sections: BTreeMap::new(), templates: tera, @@ -130,7 +130,7 @@ impl Site { grandparent_paths.entry(grand_parent).or_insert_with(|| vec![]).push(section.clone()); } - for (parent_path, section) in sections.iter_mut() { + for (parent_path, section) in &mut sections { match grandparent_paths.get(parent_path) { Some(paths) => section.subsections.extend(paths.clone()), None => continue, @@ -219,7 +219,7 @@ impl Site { // Copy the nesting of the content directory if we have sections for that page let mut current_path = public.to_path_buf(); - for component in page.url.split("/") { + for component in page.url.split('/') { current_path.push(component); if !current_path.exists() { diff --git a/tests/site.rs b/tests/site.rs index 7172c9fd..1c651621 100644 --- a/tests/site.rs +++ b/tests/site.rs @@ -23,34 +23,34 @@ fn test_can_parse_site() { let posts_path = path.join("content").join("posts"); // Make sure we remove all the pwd + content from the sections - let basic = site.pages.get(&posts_path.join("simple.md")).unwrap(); + let basic = &site.pages[&posts_path.join("simple.md")]; assert_eq!(basic.components, vec!["posts".to_string()]); // Make sure the page with a url doesn't have any sections - let url_post = site.pages.get(&posts_path.join("fixed-url.md")).unwrap(); + let url_post = &site.pages[&posts_path.join("fixed-url.md")]; assert!(url_post.components.is_empty()); // Make sure the article in a folder with only asset doesn't get counted as a section - let asset_folder_post = site.pages.get(&posts_path.join("with-assets").join("index.md")).unwrap(); + let asset_folder_post = &site.pages[&posts_path.join("with-assets").join("index.md")]; assert_eq!(asset_folder_post.components, vec!["posts".to_string()]); // That we have the right number of sections assert_eq!(site.sections.len(), 4); // And that the sections are correct - let posts_section = site.sections.get(&posts_path).unwrap(); + let posts_section = &site.sections[&posts_path]; assert_eq!(posts_section.subsections.len(), 1); assert_eq!(posts_section.pages.len(), 5); - let tutorials_section = site.sections.get(&posts_path.join("tutorials")).unwrap(); + let tutorials_section = &site.sections[&posts_path.join("tutorials")]; assert_eq!(tutorials_section.subsections.len(), 2); assert_eq!(tutorials_section.pages.len(), 0); - let devops_section = site.sections.get(&posts_path.join("tutorials").join("devops")).unwrap(); + let devops_section = &site.sections[&posts_path.join("tutorials").join("devops")]; assert_eq!(devops_section.subsections.len(), 0); assert_eq!(devops_section.pages.len(), 2); - let prog_section = site.sections.get(&posts_path.join("tutorials").join("programming")).unwrap(); + let prog_section = &site.sections[&posts_path.join("tutorials").join("programming")]; assert_eq!(prog_section.subsections.len(), 0); assert_eq!(prog_section.pages.len(), 2); }