From cca6de386c3d46de3763260449fda1773043fea9 Mon Sep 17 00:00:00 2001 From: Bill Fraser Date: Fri, 24 Nov 2023 17:32:44 -0800 Subject: [PATCH] clippy --- src/analysis.rs | 2 +- src/browser_rustdoc.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/analysis.rs b/src/analysis.rs index 5f6fbdc..0ee347a 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -44,7 +44,7 @@ impl Analysis { pub fn load(workspace_path: impl Into) -> anyhow::Result { let root: PathBuf = workspace_path.into().join("target").join(SUBDIR).join("doc"); let mut crates = HashMap::new(); - for res in fs::read_dir(&root)? { + for res in fs::read_dir(root)? { let entry = res?; if entry.file_name().as_encoded_bytes().ends_with(b".json") { let path = entry.path(); diff --git a/src/browser_rustdoc.rs b/src/browser_rustdoc.rs index 0e6675b..5d868ea 100644 --- a/src/browser_rustdoc.rs +++ b/src/browser_rustdoc.rs @@ -133,7 +133,7 @@ fn item_label(item: &rustdoc_types::Item) -> String { Import(i) => return format!("use {}", i.source), // TODO: globs Union(_) => "union", Struct(_) => "struct", - StructField(f) => return format!("{}: {}", name, type_label(&f)), + StructField(f) => return format!("{}: {}", name, type_label(f)), Enum(_) => "enum", Variant(_) => "enum variant", Function(_) => "fn", // TODO: include signature? @@ -157,14 +157,14 @@ fn item_label(item: &rustdoc_types::Item) -> String { Primitive(_) => "", AssocConst { type_, default } => { return if let Some(default) = default { - format!("const {name}: {} = {default}", type_label(&type_)) + format!("const {name}: {} = {default}", type_label(type_)) } else { - format!("const {name}: {}", type_label(&type_)) + format!("const {name}: {}", type_label(type_)) } } AssocType { default, .. } => { return if let Some(default) = default { - format!("type {name} = {}", type_label(&default)) + format!("type {name} = {}", type_label(default)) } else { format!("type {name}") }; @@ -186,13 +186,13 @@ fn type_label(ty: &rustdoc_types::Type) -> String { .collect::>() .join(", "); let ret = match &fp.decl.output { - Some(ty) => format!(" -> {}", type_label(&ty)), + Some(ty) => format!(" -> {}", type_label(ty)), None => String::new(), }; format!("fn({args}){ret}") }, Tuple(types) => format!("({})", - types.iter().map(|ty| type_label(ty)).collect::>().join(", ")), + types.iter().map(type_label).collect::>().join(", ")), Slice(ty) => format!("&[{}]", type_label(ty)), Array { type_, len } => format!("[{}; {len}]", type_label(type_)), ImplTrait(_) => todo!(),