From f58e416b96c5f9df23df904c5cbb08af4e085d1e Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 31 Aug 2017 18:01:26 +0900 Subject: [PATCH] Clippy run --- components/config/src/lib.rs | 6 +++--- components/config/src/theme.rs | 2 +- components/content/benches/all.rs | 4 ++-- components/site/src/lib.rs | 4 ++-- components/templates/src/global_fns.rs | 2 +- src/prompt.rs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/config/src/lib.rs b/components/config/src/lib.rs index 76b93aef..4663d249 100644 --- a/components/config/src/lib.rs +++ b/components/config/src/lib.rs @@ -138,12 +138,12 @@ impl Config { let original = config_extra.clone(); // 2. inject theme extra values for (key, val) in &theme.extra { - config_extra.entry(key.to_string()).or_insert(val.clone()); + config_extra.entry(key.to_string()).or_insert_with(|| val.clone()); } // 3. overwrite with original config for (key, val) in &original { - config_extra.entry(key.to_string()).or_insert(val.clone()); + config_extra.entry(key.to_string()).or_insert_with(|| val.clone()); } } @@ -171,7 +171,7 @@ impl Default for Config { description: None, language_code: Some("en".to_string()), generate_rss: Some(false), - rss_limit: Some(10000), + rss_limit: Some(10_000), generate_tags_pages: Some(true), generate_categories_pages: Some(true), insert_anchor_links: Some(false), diff --git a/components/config/src/theme.rs b/components/config/src/theme.rs index 6a6d1d8e..7c054912 100644 --- a/components/config/src/theme.rs +++ b/components/config/src/theme.rs @@ -26,7 +26,7 @@ impl Theme { }; let mut extra = HashMap::new(); - if let Some(ref theme_table) = theme.as_table() { + if let Some(theme_table) = theme.as_table() { if let Some(ex) = theme_table.get("extra") { if ex.is_table() { extra = ex.clone().try_into().unwrap(); diff --git a/components/content/benches/all.rs b/components/content/benches/all.rs index 19b5454c..cb80fdbb 100644 --- a/components/content/benches/all.rs +++ b/components/content/benches/all.rs @@ -131,14 +131,14 @@ fn bench_sorting_order(b: &mut test::Bencher) { fn bench_populate_previous_and_next_pages(b: &mut test::Bencher) { let pages = create_pages(250, SortBy::Order); let (sorted_pages, _) = sort_pages(pages, SortBy::Order); - b.iter(|| populate_previous_and_next_pages(sorted_pages.clone())); + b.iter(|| populate_previous_and_next_pages(&sorted_pages.clone())); } #[bench] fn bench_page_render_html(b: &mut test::Bencher) { let pages = create_pages(10, SortBy::Order); let (mut sorted_pages, _) = sort_pages(pages, SortBy::Order); - sorted_pages = populate_previous_and_next_pages(sorted_pages.clone()); + sorted_pages = populate_previous_and_next_pages(&sorted_pages); let config = Config::default(); let mut tera = Tera::default(); diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 71ecc360..557e9a1f 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -629,7 +629,7 @@ impl Site { let sitemap = &render_template("sitemap.xml", &self.tera, &context, self.config.theme.clone())?; - create_file(&self.output_path.join("sitemap.xml"), &sitemap)?; + create_file(&self.output_path.join("sitemap.xml"), sitemap)?; Ok(()) } @@ -663,7 +663,7 @@ impl Site { let feed = &render_template("rss.xml", &self.tera, &context, self.config.theme.clone())?; - create_file(&self.output_path.join("rss.xml"), &feed)?; + create_file(&self.output_path.join("rss.xml"), feed)?; Ok(()) } diff --git a/components/templates/src/global_fns.rs b/components/templates/src/global_fns.rs index b9086cb0..ba3c0939 100644 --- a/components/templates/src/global_fns.rs +++ b/components/templates/src/global_fns.rs @@ -79,7 +79,7 @@ pub fn make_get_url(permalinks: HashMap, config: Config) -> Glob if cachebust { permalink = format!("{}?t={}", permalink, config.build_timestamp.unwrap()); } - return Ok(to_value(permalink).unwrap()); + Ok(to_value(permalink).unwrap()) } }, Err(_) => Err(format!("`get_url` received path={:?} but it requires a string", val).into()), diff --git a/src/prompt.rs b/src/prompt.rs index b51891bf..74ba9ded 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -12,7 +12,7 @@ fn read_line() -> Result { lines .next() .and_then(|l| l.ok()) - .ok_or("unable to read from stdin for confirmation".into()) + .ok_or_else(|| "unable to read from stdin for confirmation".into()) } /// Ask a yes/no question to the user