Skip to content

Commit 8344465

Browse files
authored
Merge pull request #2376 from ehuss/clippy-fixes
Apply a few minor clippy fixes
2 parents dae7490 + 5bc87d5 commit 8344465

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

src/book/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl MDBook {
330330

331331
let mut cmd = Command::new("rustdoc");
332332
cmd.current_dir(temp_dir.path())
333-
.arg(&chapter_path)
333+
.arg(chapter_path)
334334
.arg("--test")
335335
.args(&library_args);
336336

@@ -349,7 +349,7 @@ impl MDBook {
349349
}
350350

351351
if color_output {
352-
cmd.args(&["--color", "always"]);
352+
cmd.args(["--color", "always"]);
353353
}
354354

355355
debug!("running {:?}", cmd);

src/book/summary.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,13 @@ fn get_last_link(links: &mut [SummaryItem]) -> Result<(usize, &mut Link)> {
583583
.iter_mut()
584584
.enumerate()
585585
.filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l)))
586-
.rev()
587-
.next()
588-
.ok_or_else(||
589-
anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links")
586+
.next_back()
587+
.ok_or_else(|| {
588+
anyhow::anyhow!(
589+
"Unable to get last link because the list of SummaryItems \
590+
doesn't contain any Links"
590591
)
592+
})
591593
}
592594

593595
/// Removes the styling from a list of Markdown events and returns just the

src/cmd/watch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec<PathBuf> {
9999
.iter()
100100
.filter(|path| {
101101
let relative_path =
102-
diff_paths(&path, &ignore_root).expect("One of the paths should be an absolute");
102+
diff_paths(path, &ignore_root).expect("One of the paths should be an absolute");
103103
!ignore
104104
.matched_path_or_any_parents(&relative_path, relative_path.is_dir())
105105
.is_ignore()

src/config.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,21 +694,13 @@ impl Default for Playground {
694694
}
695695

696696
/// Configuration for tweaking how the HTML renderer handles code blocks.
697-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
697+
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
698698
#[serde(default, rename_all = "kebab-case")]
699699
pub struct Code {
700700
/// A prefix string to hide lines per language (one or more chars).
701701
pub hidelines: HashMap<String, String>,
702702
}
703703

704-
impl Default for Code {
705-
fn default() -> Code {
706-
Code {
707-
hidelines: HashMap::new(),
708-
}
709-
}
710-
}
711-
712704
/// Configuration of the search functionality of the HTML renderer.
713705
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
714706
#[serde(default, rename_all = "kebab-case")]

src/renderer/html_handlebars/helpers/toc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl HelperDef for RenderToc {
7575

7676
for item in chapters {
7777
// Spacer
78-
if item.get("spacer").is_some() {
78+
if item.contains_key("spacer") {
7979
out.write("<li class=\"spacer\"></li>")?;
8080
continue;
8181
}
@@ -114,7 +114,7 @@ impl HelperDef for RenderToc {
114114
write_li_open_tag(out, is_expanded, false)?;
115115
}
116116
Ordering::Equal => {
117-
write_li_open_tag(out, is_expanded, item.get("section").is_none())?;
117+
write_li_open_tag(out, is_expanded, !item.contains_key("section"))?;
118118
}
119119
}
120120

0 commit comments

Comments
 (0)