diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-08-31 12:31:55 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-07 19:31:59 -0400 |
| commit | a502e856034bcd4bc38152b3bd74cad792b62c63 (patch) | |
| tree | bb1be651ef360f12d2b6b93180a90bda09147406 | |
| parent | 17bef30d0b1cc3851fb76fdd84b4d15bb629dc39 (diff) | |
| download | rust-a502e856034bcd4bc38152b3bd74cad792b62c63.tar.gz rust-a502e856034bcd4bc38152b3bd74cad792b62c63.zip | |
AllTypes to function
| -rw-r--r-- | src/librustdoc/html/render.rs | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 2eb2ba4e2b2..ee7981aba01 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1757,8 +1757,7 @@ impl AllTypes { } } -fn print_entries(f: &mut fmt::Formatter<'_>, e: &FxHashSet<ItemEntry>, title: &str, - class: &str) -> fmt::Result { +fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str, class: &str) { if !e.is_empty() { let mut e: Vec<&ItemEntry> = e.iter().collect(); e.sort(); @@ -1766,39 +1765,38 @@ fn print_entries(f: &mut fmt::Formatter<'_>, e: &FxHashSet<ItemEntry>, title: &s title, Escape(title), class, - e.iter().map(|s| format!("<li>{}</li>", s)).collect::<String>())?; + e.iter().map(|s| format!("<li>{}</li>", s)).collect::<String>()); } - Ok(()) } -impl fmt::Display for AllTypes { -fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, -"<h1 class='fqn'>\ - <span class='out-of-band'>\ - <span id='render-detail'>\ - <a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\ - [<span class='inner'>−</span>]\ - </a>\ +impl AllTypes { + fn print(self, f: &mut Buffer) { + write!(f, + "<h1 class='fqn'>\ + <span class='out-of-band'>\ + <span id='render-detail'>\ + <a id=\"toggle-all-docs\" href=\"javascript:void(0)\" title=\"collapse all docs\">\ + [<span class='inner'>−</span>]\ + </a>\ + </span> </span> - </span> - <span class='in-band'>List of all items</span>\ -</h1>")?; - print_entries(f, &self.structs, "Structs", "structs")?; - print_entries(f, &self.enums, "Enums", "enums")?; - print_entries(f, &self.unions, "Unions", "unions")?; - print_entries(f, &self.primitives, "Primitives", "primitives")?; - print_entries(f, &self.traits, "Traits", "traits")?; - print_entries(f, &self.macros, "Macros", "macros")?; - print_entries(f, &self.attributes, "Attribute Macros", "attributes")?; - print_entries(f, &self.derives, "Derive Macros", "derives")?; - print_entries(f, &self.functions, "Functions", "functions")?; - print_entries(f, &self.typedefs, "Typedefs", "typedefs")?; - print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases")?; - print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types")?; - print_entries(f, &self.statics, "Statics", "statics")?; - print_entries(f, &self.constants, "Constants", "constants") -} + <span class='in-band'>List of all items</span>\ + </h1>"); + print_entries(f, &self.structs, "Structs", "structs"); + print_entries(f, &self.enums, "Enums", "enums"); + print_entries(f, &self.unions, "Unions", "unions"); + print_entries(f, &self.primitives, "Primitives", "primitives"); + print_entries(f, &self.traits, "Traits", "traits"); + print_entries(f, &self.macros, "Macros", "macros"); + print_entries(f, &self.attributes, "Attribute Macros", "attributes"); + print_entries(f, &self.derives, "Derive Macros", "derives"); + print_entries(f, &self.functions, "Functions", "functions"); + print_entries(f, &self.typedefs, "Typedefs", "typedefs"); + print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases"); + print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types"); + print_entries(f, &self.statics, "Statics", "statics"); + print_entries(f, &self.constants, "Constants", "constants") + } } fn settings(root_path: &str, suffix: &str) -> String { @@ -1901,7 +1899,7 @@ impl Context { String::new() }; let v = layout::render(&self.shared.layout, - &page, sidebar, |buf: &mut Buffer| buf.from_display(all), + &page, sidebar, |buf: &mut Buffer| all.print(buf), &self.shared.themes); self.shared.fs.write(&final_file, v.as_bytes())?; |
