From ac0d180c5c05200effad2d4ad9b6cf74d91746eb Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 16 Dec 2022 23:22:47 +0100 Subject: [PATCH] Apply suggestions from clippy. --- crates/project/src/docs.rs | 17 +++++++---------- crates/project/src/lib.rs | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/project/src/docs.rs b/crates/project/src/docs.rs index f7ed3a1a..7e960a38 100644 --- a/crates/project/src/docs.rs +++ b/crates/project/src/docs.rs @@ -10,7 +10,7 @@ use pulldown_cmark as markdown; use serde::Serialize; use serde_json as json; use std::{ - path::PathBuf, + path::{Path, PathBuf}, sync::Arc, time::{Duration, SystemTime}, }; @@ -75,7 +75,7 @@ struct SearchIndex { /// The documentation is built using template files located at the root of this crate. /// With the documentation, we also build a client-side search index to ease navigation /// across multiple modules. -pub fn generate_all(root: &PathBuf, config: &Config, modules: Vec<&CheckedModule>) -> Vec { +pub fn generate_all(root: &Path, config: &Config, modules: Vec<&CheckedModule>) -> Vec { let timestamp = new_timestamp(); let modules_links = generate_modules_links(&modules); @@ -243,7 +243,7 @@ fn generate_static_assets(search_indexes: Vec) -> Vec { } fn generate_readme( - root: &PathBuf, + root: &Path, config: &Config, modules: &Vec, timestamp: &Duration, @@ -414,13 +414,10 @@ struct DocTypeConstructorArg { impl DocTypeConstructorArg { fn from_record_constructor_arg(arg: &RecordConstructorArg>) -> Option { - match &arg.label { - None => None, - Some(label) => Some(DocTypeConstructorArg { - label: label.clone(), - documentation: arg.doc.as_deref().map(render_markdown).unwrap_or_default(), - }), - } + arg.label.as_ref().map(|label| DocTypeConstructorArg { + label: label.clone(), + documentation: arg.doc.as_deref().map(render_markdown).unwrap_or_default(), + }) } } diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rs index 159fe320..5f7ad8e4 100644 --- a/crates/project/src/lib.rs +++ b/crates/project/src/lib.rs @@ -107,7 +107,7 @@ where }); self.read_source_files()?; - let destination = destination.unwrap_or(self.root.join("doc")); + let destination = destination.unwrap_or_else(|| self.root.join("doc")); let mut parsed_modules = self.parse_sources()?; for (_, module) in parsed_modules.iter_mut() { module.attach_doc_and_module_comments(); @@ -120,7 +120,7 @@ where docs::generate_all(&self.root, &self.config, checked_modules.values().collect()); for file in doc_files { let path = destination.join(file.path); - fs::create_dir_all(&path.parent().unwrap())?; + fs::create_dir_all(path.parent().unwrap())?; fs::write(&path, file.content)?; }