Skip to content

Commit 9f02e1a

Browse files
committed
rustdoc: Render [src] links for trait implementors (#43893)
1 parent 87d7520 commit 9f02e1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustdoc/html/render.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,16 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
24892489
write!(w, "{}", impl_header)?;
24902490

24912491
for implementor in local {
2492-
write!(w, "<li><code>")?;
2492+
write!(w, "<li>")?;
2493+
if let Some(item) = implementor2item(&cache, implementor) {
2494+
if let Some(l) = (Item { cx, item }).src_href() {
2495+
write!(w, "<div class='out-of-band'>")?;
2496+
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2497+
l, "goto source code")?;
2498+
write!(w, "</div>")?;
2499+
}
2500+
}
2501+
write!(w, "<code>")?;
24932502
// If there's already another implementor that has the same abbridged name, use the
24942503
// full path, for example in `std::iter::ExactSizeIterator`
24952504
let use_absolute = match implementor.impl_.for_ {

0 commit comments

Comments
 (0)