summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2024-05-13 12:13:50 -0700
committerEric Huss <eric@huss.org>2024-05-13 12:13:50 -0700
commit5bc87d5c175e1699d3705fcfa097644ef25449e4 (patch)
treed96f40f2465ebd5a400e3b8642ae10e4fa3e760e
parent09576d7d57560b731e34cd6e46bf9e2098133e96 (diff)
Apply a few minor clippy fixes
-rw-r--r--src/book/mod.rs4
-rw-r--r--src/book/summary.rs10
-rw-r--r--src/cmd/watch.rs2
-rw-r--r--src/config.rs10
-rw-r--r--src/renderer/html_handlebars/helpers/toc.rs4
5 files changed, 12 insertions, 18 deletions
diff --git a/src/book/mod.rs b/src/book/mod.rs
index 6adc02ec..e66615e2 100644
--- a/src/book/mod.rs
+++ b/src/book/mod.rs
@@ -330,7 +330,7 @@ impl MDBook {
let mut cmd = Command::new("rustdoc");
cmd.current_dir(temp_dir.path())
- .arg(&chapter_path)
+ .arg(chapter_path)
.arg("--test")
.args(&library_args);
@@ -349,7 +349,7 @@ impl MDBook {
}
if color_output {
- cmd.args(&["--color", "always"]);
+ cmd.args(["--color", "always"]);
}
debug!("running {:?}", cmd);
diff --git a/src/book/summary.rs b/src/book/summary.rs
index 5ac22b98..6c71e54e 100644
--- a/src/book/summary.rs
+++ b/src/book/summary.rs
@@ -583,11 +583,13 @@ fn get_last_link(links: &mut [SummaryItem]) -> Result<(usize, &mut Link)> {
.iter_mut()
.enumerate()
.filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l)))
- .rev()
- .next()
- .ok_or_else(||
- anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links")
+ .next_back()
+ .ok_or_else(|| {
+ anyhow::anyhow!(
+ "Unable to get last link because the list of SummaryItems \
+ doesn't contain any Links"
)
+ })
}
/// Removes the styling from a list of Markdown events and returns just the
diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs
index 80b9ff1b..ef3371d8 100644
--- a/src/cmd/watch.rs
+++ b/src/cmd/watch.rs
@@ -99,7 +99,7 @@ fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec<PathBuf> {
.iter()
.filter(|path| {
let relative_path =
- diff_paths(&path, &ignore_root).expect("One of the paths should be an absolute");
+ diff_paths(path, &ignore_root).expect("One of the paths should be an absolute");
!ignore
.matched_path_or_any_parents(&relative_path, relative_path.is_dir())
.is_ignore()
diff --git a/src/config.rs b/src/config.rs
index b7c01599..eba95286 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -694,21 +694,13 @@ impl Default for Playground {
}
/// Configuration for tweaking how the HTML renderer handles code blocks.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[derive(Debug, Default, 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<String, String>,
}
-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/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs
index a7483bb1..81da5ef5 100644
--- a/src/renderer/html_handlebars/helpers/toc.rs
+++ b/src/renderer/html_handlebars/helpers/toc.rs
@@ -75,7 +75,7 @@ impl HelperDef for RenderToc {
for item in chapters {
// Spacer
- if item.get("spacer").is_some() {
+ if item.contains_key("spacer") {
out.write("<li class=\"spacer\"></li>")?;
continue;
}
@@ -114,7 +114,7 @@ impl HelperDef for RenderToc {
write_li_open_tag(out, is_expanded, false)?;
}
Ordering::Equal => {
- write_li_open_tag(out, is_expanded, item.get("section").is_none())?;
+ write_li_open_tag(out, is_expanded, !item.contains_key("section"))?;
}
}