Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
wfraser committed Nov 25, 2023
1 parent 79e94d9 commit cca6de3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Analysis {
pub fn load(workspace_path: impl Into<PathBuf>) -> anyhow::Result<Self> {
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();
Expand Down
12 changes: 6 additions & 6 deletions src/browser_rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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}")
};
Expand All @@ -186,13 +186,13 @@ fn type_label(ty: &rustdoc_types::Type) -> String {
.collect::<Vec<_>>()
.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::<Vec<_>>().join(", ")),
types.iter().map(type_label).collect::<Vec<_>>().join(", ")),
Slice(ty) => format!("&[{}]", type_label(ty)),
Array { type_, len } => format!("[{}; {len}]", type_label(type_)),
ImplTrait(_) => todo!(),
Expand Down

0 comments on commit cca6de3

Please sign in to comment.