Skip to content

Commit 27a420f

Browse files
Unify generation of section on "All items" page with all other pages
1 parent 4a3109e commit 27a420f

File tree

1 file changed

+18
-18
lines changed
  • src/librustdoc/html/render

1 file changed

+18
-18
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@ impl AllTypes {
341341
}
342342

343343
fn print(self, f: &mut Buffer) {
344-
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str) {
344+
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, kind: ItemSection) {
345345
if !e.is_empty() {
346346
let mut e: Vec<&ItemEntry> = e.iter().collect();
347347
e.sort();
348348
write!(
349349
f,
350-
"<h3 id=\"{}\">{}</h3><ul class=\"all-items\">",
351-
title.replace(' ', "-"), // IDs cannot contain whitespaces.
352-
title
350+
"<h3 id=\"{id}\">{title}</h3><ul class=\"all-items\">",
351+
id = kind.id(),
352+
title = kind.name(),
353353
);
354354

355355
for s in e.iter() {
@@ -367,20 +367,20 @@ impl AllTypes {
367367
);
368368
// Note: print_entries does not escape the title, because we know the current set of titles
369369
// doesn't require escaping.
370-
print_entries(f, &self.structs, "Structs");
371-
print_entries(f, &self.enums, "Enums");
372-
print_entries(f, &self.unions, "Unions");
373-
print_entries(f, &self.primitives, "Primitives");
374-
print_entries(f, &self.traits, "Traits");
375-
print_entries(f, &self.macros, "Macros");
376-
print_entries(f, &self.attributes, "Attribute Macros");
377-
print_entries(f, &self.derives, "Derive Macros");
378-
print_entries(f, &self.functions, "Functions");
379-
print_entries(f, &self.typedefs, "Typedefs");
380-
print_entries(f, &self.trait_aliases, "Trait Aliases");
381-
print_entries(f, &self.opaque_tys, "Opaque Types");
382-
print_entries(f, &self.statics, "Statics");
383-
print_entries(f, &self.constants, "Constants");
370+
print_entries(f, &self.structs, ItemSection::Structs);
371+
print_entries(f, &self.enums, ItemSection::Enums);
372+
print_entries(f, &self.unions, ItemSection::Unions);
373+
print_entries(f, &self.primitives, ItemSection::PrimitiveTypes);
374+
print_entries(f, &self.traits, ItemSection::Traits);
375+
print_entries(f, &self.macros, ItemSection::Macros);
376+
print_entries(f, &self.attributes, ItemSection::AttributeMacros);
377+
print_entries(f, &self.derives, ItemSection::DeriveMacros);
378+
print_entries(f, &self.functions, ItemSection::Functions);
379+
print_entries(f, &self.typedefs, ItemSection::TypeDefinitions);
380+
print_entries(f, &self.trait_aliases, ItemSection::TraitAliases);
381+
print_entries(f, &self.opaque_tys, ItemSection::OpaqueTypes);
382+
print_entries(f, &self.statics, ItemSection::Statics);
383+
print_entries(f, &self.constants, ItemSection::Constants);
384384
}
385385
}
386386

0 commit comments

Comments
 (0)