Apply suggestions from clippy.

This commit is contained in:
KtorZ 2022-12-16 23:22:47 +01:00
parent 873bd85d8b
commit ac0d180c5c
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 9 additions and 12 deletions

View File

@ -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<DocFile> {
pub fn generate_all(root: &Path, config: &Config, modules: Vec<&CheckedModule>) -> Vec<DocFile> {
let timestamp = new_timestamp();
let modules_links = generate_modules_links(&modules);
@ -243,7 +243,7 @@ fn generate_static_assets(search_indexes: Vec<SearchIndex>) -> Vec<DocFile> {
}
fn generate_readme(
root: &PathBuf,
root: &Path,
config: &Config,
modules: &Vec<DocLink>,
timestamp: &Duration,
@ -414,13 +414,10 @@ struct DocTypeConstructorArg {
impl DocTypeConstructorArg {
fn from_record_constructor_arg(arg: &RecordConstructorArg<Arc<Type>>) -> Option<Self> {
match &arg.label {
None => None,
Some(label) => Some(DocTypeConstructorArg {
arg.label.as_ref().map(|label| DocTypeConstructorArg {
label: label.clone(),
documentation: arg.doc.as_deref().map(render_markdown).unwrap_or_default(),
}),
}
})
}
}

View File

@ -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)?;
}