Apply a few minor clippy fixes

This commit is contained in:
Eric Huss 2024-05-13 12:13:50 -07:00
parent 09576d7d57
commit 5bc87d5c17
5 changed files with 12 additions and 18 deletions

View file

@ -330,7 +330,7 @@ impl MDBook {
let mut cmd = Command::new("rustdoc"); let mut cmd = Command::new("rustdoc");
cmd.current_dir(temp_dir.path()) cmd.current_dir(temp_dir.path())
.arg(&chapter_path) .arg(chapter_path)
.arg("--test") .arg("--test")
.args(&library_args); .args(&library_args);
@ -349,7 +349,7 @@ impl MDBook {
} }
if color_output { if color_output {
cmd.args(&["--color", "always"]); cmd.args(["--color", "always"]);
} }
debug!("running {:?}", cmd); debug!("running {:?}", cmd);

View file

@ -583,11 +583,13 @@ fn get_last_link(links: &mut [SummaryItem]) -> Result<(usize, &mut Link)> {
.iter_mut() .iter_mut()
.enumerate() .enumerate()
.filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l))) .filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l)))
.rev() .next_back()
.next() .ok_or_else(|| {
.ok_or_else(|| anyhow::anyhow!(
anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links") "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 /// Removes the styling from a list of Markdown events and returns just the

View file

@ -99,7 +99,7 @@ fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec<PathBuf> {
.iter() .iter()
.filter(|path| { .filter(|path| {
let relative_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 !ignore
.matched_path_or_any_parents(&relative_path, relative_path.is_dir()) .matched_path_or_any_parents(&relative_path, relative_path.is_dir())
.is_ignore() .is_ignore()

View file

@ -694,21 +694,13 @@ impl Default for Playground {
} }
/// Configuration for tweaking how the HTML renderer handles code blocks. /// 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")] #[serde(default, rename_all = "kebab-case")]
pub struct Code { pub struct Code {
/// A prefix string to hide lines per language (one or more chars). /// A prefix string to hide lines per language (one or more chars).
pub hidelines: HashMap<String, String>, 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. /// Configuration of the search functionality of the HTML renderer.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")] #[serde(default, rename_all = "kebab-case")]

View file

@ -75,7 +75,7 @@ impl HelperDef for RenderToc {
for item in chapters { for item in chapters {
// Spacer // Spacer
if item.get("spacer").is_some() { if item.contains_key("spacer") {
out.write("<li class=\"spacer\"></li>")?; out.write("<li class=\"spacer\"></li>")?;
continue; continue;
} }
@ -114,7 +114,7 @@ impl HelperDef for RenderToc {
write_li_open_tag(out, is_expanded, false)?; write_li_open_tag(out, is_expanded, false)?;
} }
Ordering::Equal => { 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"))?;
} }
} }