diff --git a/components/content/src/file_info.rs b/components/content/src/file_info.rs index 3f40e08c8f..8d910abaf4 100644 --- a/components/content/src/file_info.rs +++ b/components/content/src/file_info.rs @@ -57,7 +57,7 @@ impl FileInfo { let name = path.file_stem().unwrap().to_string_lossy().to_string(); let canonical = parent.join(&name); let mut components = - find_content_components(&file_path.strip_prefix(base_path).unwrap_or(&file_path)); + find_content_components(file_path.strip_prefix(base_path).unwrap_or(&file_path)); let relative = if !components.is_empty() { format!("{}/{}.md", components.join("/"), name) } else { @@ -91,7 +91,7 @@ impl FileInfo { let parent = path.parent().expect("Get parent of section").to_path_buf(); let name = path.file_stem().unwrap().to_string_lossy().to_string(); let components = - find_content_components(&file_path.strip_prefix(base_path).unwrap_or(&file_path)); + find_content_components(file_path.strip_prefix(base_path).unwrap_or(&file_path)); let relative = if !components.is_empty() { format!("{}/{}.md", components.join("/"), name) } else { diff --git a/components/content/src/library.rs b/components/content/src/library.rs index f2aae54d0b..485b88dacd 100644 --- a/components/content/src/library.rs +++ b/components/content/src/library.rs @@ -295,7 +295,7 @@ impl Library { for (path, page) in self.pages.iter_mut() { let parent_filename = &index_filename_by_lang[&page.lang]; add_translation(&page.file.canonical, path); - let mut parent_section_path = page.file.parent.join(&parent_filename); + let mut parent_section_path = page.file.parent.join(parent_filename); while let Some(parent_section) = self.sections.get_mut(&parent_section_path) { let is_transparent = parent_section.meta.transparent; @@ -323,7 +323,7 @@ impl Library { // We've added `_index(.{LANG})?.md` so if we are here so we need to go up twice match parent_section_path.clone().parent().unwrap().parent() { - Some(parent) => parent_section_path = parent.join(&parent_filename), + Some(parent) => parent_section_path = parent.join(parent_filename), None => break, } } diff --git a/components/content/src/page.rs b/components/content/src/page.rs index 1e1ae8fbbe..b23983dced 100644 --- a/components/content/src/page.rs +++ b/components/content/src/page.rs @@ -31,7 +31,9 @@ static RFC3339_DATE: Lazy = Lazy::new(|| { ).unwrap() }); -static FOOTNOTES_RE: Lazy = Lazy::new(|| Regex::new(r#"\s*.*?"#).unwrap()); +static FOOTNOTES_RE: Lazy = Lazy::new(|| { + Regex::new(r#"\s*.*?"#).unwrap() +}); #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Page { @@ -260,7 +262,7 @@ impl Page { fn serialize_assets(&self, base_path: &Path) -> Vec { self.assets .iter() - .filter_map(|asset| asset.strip_prefix(&self.file.path.parent().unwrap()).ok()) + .filter_map(|asset| asset.strip_prefix(self.file.path.parent().unwrap()).ok()) .filter_map(|filename| filename.to_str()) .map(|filename| { let mut path = self.file.path.clone(); diff --git a/components/content/src/pagination.rs b/components/content/src/pagination.rs index 28182473c2..121351424a 100644 --- a/components/content/src/pagination.rs +++ b/components/content/src/pagination.rs @@ -205,7 +205,7 @@ impl<'a> Paginator<'a> { } else { paginator.insert("next", Value::Null); } - paginator.insert("number_pagers", to_value(&self.pagers.len()).unwrap()); + paginator.insert("number_pagers", to_value(self.pagers.len()).unwrap()); let base_url = if self.paginate_path.is_empty() { self.permalink.to_string() } else { diff --git a/components/content/src/section.rs b/components/content/src/section.rs index 83ca014ea7..f5695bad46 100644 --- a/components/content/src/section.rs +++ b/components/content/src/section.rs @@ -198,7 +198,7 @@ impl Section { fn serialize_assets(&self) -> Vec { self.assets .iter() - .filter_map(|asset| asset.strip_prefix(&self.file.path.parent().unwrap()).ok()) + .filter_map(|asset| asset.strip_prefix(self.file.path.parent().unwrap()).ok()) .filter_map(|filename| filename.to_str()) .map(|filename| format!("{}{}", self.path, filename)) .collect() diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index d897d06ba0..fe925b0647 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -605,7 +605,7 @@ pub fn read_image_metadata>(path: P) -> Result match ext.as_str() { "svg" => { - let img = SvgMetadata::parse_file(&path).with_context(err_context)?; + let img = SvgMetadata::parse_file(path).with_context(err_context)?; match (img.height(), img.width(), img.view_box()) { (Some(h), Some(w), _) => Ok((h, w)), (_, _, Some(view_box)) => Ok((view_box.height, view_box.width)), diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 079bc65635..2f0c82688e 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -218,7 +218,7 @@ impl Site { // if we are processing a section we have to collect // index files for all languages and process them simultaneously // before any of the pages - let index_files = WalkDir::new(&path) + let index_files = WalkDir::new(path) .follow_links(true) .max_depth(1) .into_iter() @@ -664,7 +664,7 @@ impl Site { asset_path, ¤t_path.join( asset_path - .strip_prefix(&page.file.path.parent().unwrap()) + .strip_prefix(page.file.path.parent().unwrap()) .expect("Couldn't get filename from page asset"), ), )?; @@ -1071,7 +1071,7 @@ impl Site { asset_path, &output_path.join( asset_path - .strip_prefix(§ion.file.path.parent().unwrap()) + .strip_prefix(section.file.path.parent().unwrap()) .expect("Failed to get asset filename for section"), ), )?; diff --git a/components/site/src/sass.rs b/components/site/src/sass.rs index f178d3e8cb..03525d6163 100644 --- a/components/site/src/sass.rs +++ b/components/site/src/sass.rs @@ -51,12 +51,12 @@ fn compile_sass_glob( for file in files { let css = compile_file(&file, options.clone()).map_err(|e| anyhow!(e))?; - let path_inside_sass = file.strip_prefix(&sass_path).unwrap(); + let path_inside_sass = file.strip_prefix(sass_path).unwrap(); let parent_inside_sass = path_inside_sass.parent(); let css_output_path = output_path.join(path_inside_sass).with_extension("css"); if parent_inside_sass.is_some() { - create_dir_all(&css_output_path.parent().unwrap())?; + create_dir_all(css_output_path.parent().unwrap())?; } create_file(&css_output_path, &css)?; diff --git a/components/templates/src/lib.rs b/components/templates/src/lib.rs index 120b8fc88b..90578d4093 100644 --- a/components/templates/src/lib.rs +++ b/components/templates/src/lib.rs @@ -62,7 +62,7 @@ pub fn load_tera(path: &Path, config: &Config) -> Result { if let Some(ref theme) = config.theme { // Test that the templates folder exist for that theme - let theme_path = path.join("themes").join(&theme); + let theme_path = path.join("themes").join(theme); if !theme_path.join("templates").exists() { bail!("Theme `{}` is missing a templates folder", theme); } diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs index 8d3c22c8a8..c5567f07fe 100644 --- a/components/utils/src/fs.rs +++ b/components/utils/src/fs.rs @@ -21,7 +21,7 @@ pub fn is_path_in_directory(parent: &Path, path: &Path) -> Result { /// Create a file with the content given pub fn create_file(path: &Path, content: &str) -> Result<()> { let mut file = - File::create(&path).with_context(|| format!("Failed to create file {}", path.display()))?; + File::create(path).with_context(|| format!("Failed to create file {}", path.display()))?; file.write_all(content.as_bytes())?; Ok(()) } @@ -92,19 +92,19 @@ pub fn copy_file_if_needed(src: &Path, dest: &Path, hard_link: bool) -> Result<( .with_context(|| format!("Failed to get metadata of {}", src.display()))?; let src_mtime = FileTime::from_last_modification_time(&src_metadata); if Path::new(&dest).is_file() { - let target_metadata = metadata(&dest)?; + let target_metadata = metadata(dest)?; let target_mtime = FileTime::from_last_modification_time(&target_metadata); if !(src_mtime == target_mtime && src_metadata.len() == target_metadata.len()) { - copy(src, &dest).with_context(|| { + copy(src, dest).with_context(|| { format!("Was not able to copy file {} to {}", src.display(), dest.display()) })?; - set_file_mtime(&dest, src_mtime)?; + set_file_mtime(dest, src_mtime)?; } } else { - copy(src, &dest).with_context(|| { + copy(src, dest).with_context(|| { format!("Was not able to copy directory {} to {}", src.display(), dest.display()) })?; - set_file_mtime(&dest, src_mtime)?; + set_file_mtime(dest, src_mtime)?; } } Ok(()) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 785f9f15a3..791ad63b6f 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -318,13 +318,12 @@ pub fn serve( Ok(a) => a, Err(_) => return Err(anyhow!("Invalid address: {}.", address)), }; - if (TcpListener::bind(&bind_address)).is_err() { + if (TcpListener::bind(bind_address)).is_err() { return Err(anyhow!("Cannot start server on address {}.", address)); } let config_path = PathBuf::from(config_file); - let config_path_rel = - diff_paths(&config_path, &root_dir).unwrap_or_else(|| config_path.clone()); + let config_path_rel = diff_paths(&config_path, root_dir).unwrap_or_else(|| config_path.clone()); // An array of (path, WatchMode) where the path should be watched for changes, // and the WatchMode value indicates whether this file/folder must exist for diff --git a/src/main.rs b/src/main.rs index 05542e6149..6f3fcdfeb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,12 +15,12 @@ mod prompt; fn get_config_file_path(dir: &Path, config_path: &Path) -> (PathBuf, PathBuf) { let root_dir = dir .ancestors() - .find(|a| a.join(&config_path).exists()) + .find(|a| a.join(config_path).exists()) .unwrap_or_else(|| panic!("could not find directory containing config file")); // if we got here we found root_dir so config file should exist so we can unwrap safely let config_file = root_dir - .join(&config_path) + .join(config_path) .canonicalize() .unwrap_or_else(|_| panic!("could not find directory containing config file")); (root_dir.to_path_buf(), config_file)