Skip to content

Commit 780719b

Browse files
committed
Migrate to Askama
Implemented wrap_item_write Update wrap_item
1 parent 2560b80 commit 780719b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/librustdoc/html/render/print_item.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,12 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
11021102
);
11031103
}
11041104

1105-
fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TraitAlias) {
1105+
fn item_trait_alias(
1106+
w: &mut impl fmt::Write,
1107+
cx: &mut Context<'_>,
1108+
it: &clean::Item,
1109+
t: &clean::TraitAlias,
1110+
) {
11061111
wrap_item(w, |w| {
11071112
write!(
11081113
w,
@@ -1112,16 +1117,17 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &
11121117
print_where_clause(&t.generics, cx, 0, Ending::Newline),
11131118
bounds(&t.bounds, true, cx),
11141119
attrs = render_attributes_in_pre(it, "", cx.tcx()),
1115-
);
1120+
)
1121+
.unwrap();
11161122
});
11171123

1118-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
1119-
1124+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
11201125
// Render any items associated directly to this alias, as otherwise they
11211126
// won't be visible anywhere in the docs. It would be nice to also show
11221127
// associated items from the aliased type (see discussion in #32077), but
11231128
// we need #14072 to make sense of the generics.
11241129
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1130+
.unwrap();
11251131
}
11261132

11271133
fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::OpaqueTy) {
@@ -1666,13 +1672,14 @@ fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>)
16661672
bounds
16671673
}
16681674

1669-
fn wrap_item<F>(w: &mut Buffer, f: F)
1675+
fn wrap_item<W, F>(w: &mut W, f: F)
16701676
where
1671-
F: FnOnce(&mut Buffer),
1677+
W: fmt::Write,
1678+
F: FnOnce(&mut W),
16721679
{
1673-
w.write_str(r#"<pre class="rust item-decl"><code>"#);
1680+
write!(w, r#"<pre class="rust item-decl"><code>"#).unwrap();
16741681
f(w);
1675-
w.write_str("</code></pre>");
1682+
write!(w, "</code></pre>").unwrap();
16761683
}
16771684

16781685
#[derive(PartialEq, Eq)]

0 commit comments

Comments
 (0)