Skip to content

Commit 78ff5dd

Browse files
committed
Remove usages of write_str from render_assoc_items_inner
1 parent 40ace17 commit 78ff5dd

File tree

2 files changed

+22
-41
lines changed

2 files changed

+22
-41
lines changed

src/librustdoc/html/format.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ use crate::html::escape::{Escape, EscapeBodyText};
3737
use crate::html::render::Context;
3838
use crate::passes::collect_intra_doc_links::UrlFragment;
3939

40-
pub(crate) fn write_str(s: &mut String, f: fmt::Arguments<'_>) {
41-
s.write_fmt(f).unwrap();
42-
}
43-
4440
pub(crate) fn print_generic_bounds(
4541
bounds: &[clean::GenericBound],
4642
cx: &Context<'_>,

src/librustdoc/html/render/mod.rs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,12 +1472,10 @@ fn render_assoc_items_inner(
14721472
)
14731473
}
14741474
};
1475-
let mut impls_buf = String::new();
1476-
for i in &non_trait {
1477-
write_str(
1478-
&mut impls_buf,
1479-
format_args!(
1480-
"{}",
1475+
let impls_buf = fmt::from_fn(|f| {
1476+
non_trait
1477+
.iter()
1478+
.map(|i| {
14811479
render_impl(
14821480
cx,
14831481
i,
@@ -1493,9 +1491,11 @@ fn render_assoc_items_inner(
14931491
toggle_open_by_default: true,
14941492
},
14951493
)
1496-
),
1497-
);
1498-
}
1494+
})
1495+
.joined("", f)
1496+
})
1497+
.to_string();
1498+
14991499
if !impls_buf.is_empty() {
15001500
write!(
15011501
w,
@@ -1805,49 +1805,34 @@ fn render_impl(
18051805
document_item_info(cx, it, Some(parent))
18061806
.render_into(&mut info_buffer)
18071807
.unwrap();
1808-
write_str(
1809-
&mut doc_buffer,
1810-
format_args!("{}", document_full(item, cx, HeadingOffset::H5)),
1811-
);
1808+
doc_buffer = document_full(item, cx, HeadingOffset::H5).to_string();
18121809
short_documented = false;
18131810
} else {
18141811
// In case the item isn't documented,
18151812
// provide short documentation from the trait.
1816-
write_str(
1817-
&mut doc_buffer,
1818-
format_args!(
1819-
"{}",
1820-
document_short(
1821-
it,
1822-
cx,
1823-
link,
1824-
parent,
1825-
rendering_params.show_def_docs,
1826-
)
1827-
),
1828-
);
1813+
doc_buffer = document_short(
1814+
it,
1815+
cx,
1816+
link,
1817+
parent,
1818+
rendering_params.show_def_docs,
1819+
)
1820+
.to_string();
18291821
}
18301822
}
18311823
} else {
18321824
document_item_info(cx, item, Some(parent))
18331825
.render_into(&mut info_buffer)
18341826
.unwrap();
18351827
if rendering_params.show_def_docs {
1836-
write_str(
1837-
&mut doc_buffer,
1838-
format_args!("{}", document_full(item, cx, HeadingOffset::H5)),
1839-
);
1828+
doc_buffer = document_full(item, cx, HeadingOffset::H5).to_string();
18401829
short_documented = false;
18411830
}
18421831
}
18431832
} else {
1844-
write_str(
1845-
&mut doc_buffer,
1846-
format_args!(
1847-
"{}",
1848-
document_short(item, cx, link, parent, rendering_params.show_def_docs)
1849-
),
1850-
);
1833+
doc_buffer =
1834+
document_short(item, cx, link, parent, rendering_params.show_def_docs)
1835+
.to_string();
18511836
}
18521837
}
18531838
let mut w = if short_documented && trait_.is_some() {

0 commit comments

Comments
 (0)