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:
commit
7117b457de
2 changed files with 18 additions and 2 deletions
|
@ -64,6 +64,23 @@ crate struct Buffer {
|
||||||
buffer: String,
|
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 {
|
impl Buffer {
|
||||||
crate fn empty_from(v: &Buffer) -> Buffer {
|
crate fn empty_from(v: &Buffer) -> Buffer {
|
||||||
Buffer { for_html: v.for_html, buffer: String::new() }
|
Buffer { for_html: v.for_html, buffer: String::new() }
|
||||||
|
|
|
@ -139,8 +139,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer,
|
||||||
src_href: src_href.as_deref(),
|
src_href: src_href.as_deref(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let heading = item_vars.render().unwrap();
|
item_vars.render_into(buf).unwrap();
|
||||||
buf.write_str(&heading);
|
|
||||||
|
|
||||||
match *item.kind {
|
match *item.kind {
|
||||||
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
|
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue