From fc808f2aa8c2605e7059d05af728f92bfefab235 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 7 Apr 2021 21:14:42 +0200 Subject: [PATCH] Some clippy fixes --- components/config/src/config/markup.rs | 2 +- components/front_matter/src/lib.rs | 2 -- components/front_matter/src/page.rs | 2 +- components/imageproc/src/lib.rs | 3 +-- components/library/src/library.rs | 4 ++-- src/cmd/init.rs | 3 +-- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/components/config/src/config/markup.rs b/components/config/src/config/markup.rs index 39c686de..bb6229ee 100644 --- a/components/config/src/config/markup.rs +++ b/components/config/src/config/markup.rs @@ -59,7 +59,7 @@ impl Markdown { pub fn construct_external_link_tag(&self, url: &str, title: &str) -> String { let mut rel_opts = Vec::new(); let mut target = "".to_owned(); - let title = if title == "" { "".to_owned() } else { format!("title=\"{}\" ", title) }; + let title = if title.is_empty() { "".to_owned() } else { format!("title=\"{}\" ", title) }; if self.external_links_target_blank { // Security risk otherwise diff --git a/components/front_matter/src/lib.rs b/components/front_matter/src/lib.rs index bc7a7cf1..a8e46127 100644 --- a/components/front_matter/src/lib.rs +++ b/components/front_matter/src/lib.rs @@ -3,9 +3,7 @@ use serde_derive::{Deserialize, Serialize}; use errors::{bail, Error, Result}; use regex::Regex; -use serde_yaml; use std::path::Path; -use toml; mod page; mod section; diff --git a/components/front_matter/src/page.rs b/components/front_matter/src/page.rs index da39a5e7..16ac57c9 100644 --- a/components/front_matter/src/page.rs +++ b/components/front_matter/src/page.rs @@ -81,7 +81,7 @@ impl PageFrontMatter { } if let Some(ref path) = f.path { - if path == "" { + if path.is_empty() { bail!("`path` can't be empty if present") } } diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index 97cad10e..99b6abb9 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -319,8 +319,7 @@ impl ImageOp { Some(q) => encoder.encode(q as f32 / 100.), None => encoder.encode_lossless(), }; - let mut bytes = memory.as_bytes(); - f.write_all(&mut bytes)?; + f.write_all(&memory.as_bytes())?; } } diff --git a/components/library/src/library.rs b/components/library/src/library.rs index 817e7e55..32a708d1 100644 --- a/components/library/src/library.rs +++ b/components/library/src/library.rs @@ -84,7 +84,7 @@ impl Library { let file_path = section.file.path.clone(); let rel_path = section.path.clone(); - let mut entries = vec![rel_path.clone()]; + let mut entries = vec![rel_path]; entries.extend(section.meta.aliases.iter().map(|a| a.clone()).collect::>()); self.insert_reverse_aliases(entries, §ion.file.relative); @@ -98,7 +98,7 @@ impl Library { let file_path = page.file.path.clone(); let rel_path = page.path.clone(); - let mut entries = vec![rel_path.clone()]; + let mut entries = vec![rel_path]; entries.extend(page.meta.aliases.iter().map(|a| a.clone()).collect::>()); self.insert_reverse_aliases(entries, &page.file.relative); diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 1bc76922..2fe72aa2 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -1,6 +1,5 @@ use std::fs::{canonicalize, create_dir}; use std::path::Path; -use std::path::PathBuf; use errors::{bail, Result}; use utils::fs::create_file; @@ -68,7 +67,7 @@ pub fn is_directory_quasi_empty(path: &Path) -> Result { } // Remove the unc part of a windows path -fn strip_unc(path: &PathBuf) -> String { +fn strip_unc(path: &Path) -> String { let path_to_refine = path.to_str().unwrap(); path_to_refine.trim_start_matches(LOCAL_UNC).to_string() }