1
Fork 0

Rollup merge of #92758 - mfrw:mfrw/rustdoc-impl-write, r=GuillaumeGomez

librustdoc: impl core::fmt::Write for rustdoc::html::render::Buffer

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Fixes: #92563
This commit is contained in:
Matthias Krüger 2022-02-02 07:11:04 +01:00 committed by GitHub
commit 7117b457de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -64,6 +64,23 @@ crate struct Buffer {
buffer: String,
}
impl core::fmt::Write for Buffer {
#[inline]
fn write_str(&mut self, s: &str) -> fmt::Result {
self.buffer.write_str(s)
}
#[inline]
fn write_char(&mut self, c: char) -> fmt::Result {
self.buffer.write_char(c)
}
#[inline]
fn write_fmt(self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result {
self.buffer.write_fmt(args)
}
}
impl Buffer {
crate fn empty_from(v: &Buffer) -> Buffer {
Buffer { for_html: v.for_html, buffer: String::new() }

View file

@ -139,8 +139,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer,
src_href: src_href.as_deref(),
};
let heading = item_vars.render().unwrap();
buf.write_str(&heading);
item_vars.render_into(buf).unwrap();
match *item.kind {
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),