Skip to content

Commit a502e85

Browse files
AllTypes to function
1 parent 17bef30 commit a502e85

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

src/librustdoc/html/render.rs

+30-32
Original file line numberDiff line numberDiff line change
@@ -1757,48 +1757,46 @@ impl AllTypes {
17571757
}
17581758
}
17591759

1760-
fn print_entries(f: &mut fmt::Formatter<'_>, e: &FxHashSet<ItemEntry>, title: &str,
1761-
class: &str) -> fmt::Result {
1760+
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str, class: &str) {
17621761
if !e.is_empty() {
17631762
let mut e: Vec<&ItemEntry> = e.iter().collect();
17641763
e.sort();
17651764
write!(f, "<h3 id='{}'>{}</h3><ul class='{} docblock'>{}</ul>",
17661765
title,
17671766
Escape(title),
17681767
class,
1769-
e.iter().map(|s| format!("<li>{}</li>", s)).collect::<String>())?;
1768+
e.iter().map(|s| format!("<li>{}</li>", s)).collect::<String>());
17701769
}
1771-
Ok(())
17721770
}
17731771

1774-
impl fmt::Display for AllTypes {
1775-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1776-
write!(f,
1777-
"<h1 class='fqn'>\
1778-
<span class='out-of-band'>\
1779-
<span id='render-detail'>\
1780-
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\
1781-
[<span class='inner'>&#x2212;</span>]\
1782-
</a>\
1772+
impl AllTypes {
1773+
fn print(self, f: &mut Buffer) {
1774+
write!(f,
1775+
"<h1 class='fqn'>\
1776+
<span class='out-of-band'>\
1777+
<span id='render-detail'>\
1778+
<a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\
1779+
[<span class='inner'>&#x2212;</span>]\
1780+
</a>\
1781+
</span>
17831782
</span>
1784-
</span>
1785-
<span class='in-band'>List of all items</span>\
1786-
</h1>")?;
1787-
print_entries(f, &self.structs, "Structs", "structs")?;
1788-
print_entries(f, &self.enums, "Enums", "enums")?;
1789-
print_entries(f, &self.unions, "Unions", "unions")?;
1790-
print_entries(f, &self.primitives, "Primitives", "primitives")?;
1791-
print_entries(f, &self.traits, "Traits", "traits")?;
1792-
print_entries(f, &self.macros, "Macros", "macros")?;
1793-
print_entries(f, &self.attributes, "Attribute Macros", "attributes")?;
1794-
print_entries(f, &self.derives, "Derive Macros", "derives")?;
1795-
print_entries(f, &self.functions, "Functions", "functions")?;
1796-
print_entries(f, &self.typedefs, "Typedefs", "typedefs")?;
1797-
print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases")?;
1798-
print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types")?;
1799-
print_entries(f, &self.statics, "Statics", "statics")?;
1800-
print_entries(f, &self.constants, "Constants", "constants")
1801-
}
1783+
<span class='in-band'>List of all items</span>\
1784+
</h1>");
1785+
print_entries(f, &self.structs, "Structs", "structs");
1786+
print_entries(f, &self.enums, "Enums", "enums");
1787+
print_entries(f, &self.unions, "Unions", "unions");
1788+
print_entries(f, &self.primitives, "Primitives", "primitives");
1789+
print_entries(f, &self.traits, "Traits", "traits");
1790+
print_entries(f, &self.macros, "Macros", "macros");
1791+
print_entries(f, &self.attributes, "Attribute Macros", "attributes");
1792+
print_entries(f, &self.derives, "Derive Macros", "derives");
1793+
print_entries(f, &self.functions, "Functions", "functions");
1794+
print_entries(f, &self.typedefs, "Typedefs", "typedefs");
1795+
print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases");
1796+
print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types");
1797+
print_entries(f, &self.statics, "Statics", "statics");
1798+
print_entries(f, &self.constants, "Constants", "constants")
1799+
}
18021800
}
18031801

18041802
fn settings(root_path: &str, suffix: &str) -> String {
@@ -1901,7 +1899,7 @@ impl Context {
19011899
String::new()
19021900
};
19031901
let v = layout::render(&self.shared.layout,
1904-
&page, sidebar, |buf: &mut Buffer| buf.from_display(all),
1902+
&page, sidebar, |buf: &mut Buffer| all.print(buf),
19051903
&self.shared.themes);
19061904
self.shared.fs.write(&final_file, v.as_bytes())?;
19071905

0 commit comments

Comments
 (0)