From c1b2bec7d7a56909f695f103d316453dab68798e Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 30 May 2021 14:53:35 +0200 Subject: [PATCH 1/3] book: use non_exhaustive attribute for struct Book As suggested by clippy: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive --- src/book/book.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/book/book.rs b/src/book/book.rs index 048aef28..ae64b120 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -74,10 +74,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 { @@ -228,10 +228,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>( From 56ceb627b88f42c5b3ae82a5468900d4894a1640 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 30 May 2021 14:54:19 +0200 Subject: [PATCH 2/3] book: simplify is_draft_chapter As suggested by clippy: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching --- src/book/book.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/book/book.rs b/src/book/book.rs index ae64b120..e3d87600 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -200,10 +200,7 @@ impl Chapter { /// Check if the chapter is a draft chapter, meaning it has no path to a source markdown file. pub fn is_draft_chapter(&self) -> bool { - match self.path { - Some(_) => false, - None => true, - } + self.path.is_none() } } From 714c5fb81eab92adf9baa9d2b61b43511e48eebd Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 30 May 2021 14:58:50 +0200 Subject: [PATCH 3/3] renderer: remove redundant clone in CmdRenderer As suggested by clippy: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone --- src/renderer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 05a5ac6f..9d2952c1 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -166,7 +166,7 @@ impl CmdRenderer { } else { // Let this bubble through to later be handled by // handle_render_command_error. - abs_exe.to_path_buf() + abs_exe } } };