diff --git a/src/book/book.rs b/src/book/book.rs index 96c70abc..c0253b7a 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -75,10 +75,10 @@ fn create_missing(src_dir: &Path, summary: &Summary) -> Result<()> { /// [`iter()`]: #method.iter /// [`for_each_mut()`]: #method.for_each_mut #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] pub struct Book { /// The sections in this book. pub sections: Vec, - __non_exhaustive: (), } impl Book { @@ -226,10 +226,7 @@ pub(crate) fn load_book_from_disk>(summary: &Summary, src_dir: P) chapters.push(chapter); } - Ok(Book { - sections: chapters, - __non_exhaustive: (), - }) + Ok(Book { sections: chapters }) } fn load_summary_item + Clone>( diff --git a/src/book/mod.rs b/src/book/mod.rs index a5e3e78c..724dd150 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -839,7 +839,7 @@ mod tests { .and_then(Value::as_str) .unwrap(); assert_eq!(html, "html"); - let html_renderer = HtmlHandlebars::default(); + let html_renderer = HtmlHandlebars; let pre = LinkPreprocessor::new(); let should_run = preprocessor_should_run(&pre, &html_renderer, &cfg); diff --git a/src/book/summary.rs b/src/book/summary.rs index b2784ce5..0cb2aa10 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -566,9 +566,7 @@ fn get_last_link(links: &mut [SummaryItem]) -> Result<(usize, &mut Link)> { links .iter_mut() .enumerate() - .filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l))) - .rev() - .next() + .filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l))).next_back() .ok_or_else(|| anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links") ) diff --git a/src/config.rs b/src/config.rs index 4641d1a2..d4fcd206 100644 --- a/src/config.rs +++ b/src/config.rs @@ -646,21 +646,13 @@ impl Default for Playground { } /// Configuration for tweaking how the the HTML renderer handles code blocks. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case")] pub struct Code { /// A prefix string to hide lines per language (one or more chars). pub hidelines: HashMap, } -impl Default for Code { - fn default() -> Code { - Code { - hidelines: HashMap::new(), - } - } -} - /// Configuration of the search functionality of the HTML renderer. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case")] diff --git a/src/main.rs b/src/main.rs index 3e576c5b..de9f76d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ fn main() { fn create_clap_command() -> Command { let app = Command::new(crate_name!()) .about(crate_description!()) - .author("Mathieu David ") + .author("Mathieu David and edited by Mauro Gentile ") .version(VERSION) .propagate_version(true) .arg_required_else_help(true) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 709aa066..1e8b3b00 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -823,7 +823,7 @@ fn build_header_links(html: &str) -> String { // Ignore .menu-title because now it's getting detected by the regex. if let Some(classes) = caps.get(3) { - for class in classes.as_str().split(" ") { + for class in classes.as_str().split(' ') { if IGNORE_CLASS.contains(&class) { return caps[0].to_string(); } diff --git a/src/utils/fs.rs b/src/utils/fs.rs index 1c313216..8594de91 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -73,14 +73,12 @@ pub fn create_file(path: &Path) -> Result { /// Removes all the content of a directory but not the directory itself pub fn remove_dir_content(dir: &Path) -> Result<()> { - for item in fs::read_dir(dir)? { - if let Ok(item) = item { - let item = item.path(); - if item.is_dir() { - fs::remove_dir_all(item)?; - } else { - fs::remove_file(item)?; - } + for item in (fs::read_dir(dir)?).flatten() { + let item = item.path(); + if item.is_dir() { + fs::remove_dir_all(item)?; + } else { + fs::remove_file(item)?; } } Ok(()) diff --git a/tests/custom_preprocessors.rs b/tests/custom_preprocessors.rs index 8237602d..3cc67af6 100644 --- a/tests/custom_preprocessors.rs +++ b/tests/custom_preprocessors.rs @@ -17,7 +17,7 @@ fn example_supports_whatever() { let got = cmd.supports_renderer("whatever"); - assert_eq!(got, true); + assert!(got); } #[test] @@ -26,7 +26,7 @@ fn example_doesnt_support_not_supported() { let got = cmd.supports_renderer("not-supported"); - assert_eq!(got, false); + assert!(!got); } #[test] diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 7626b9e8..44b79a16 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -966,5 +966,5 @@ fn custom_header_attributes() { r##"

Heading with classes

"##, r##"

Heading with id and classes

"##, ]; - assert_contains_strings(&contents, summary_strings); + assert_contains_strings(contents, summary_strings); }