Skip to content

Commit c9bdd51

Browse files
add [src] links to associated functions inside an impl block
1 parent 5669c99 commit c9bdd51

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/librustdoc/html/render.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
29392939
write!(w, "<code>")?;
29402940
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
29412941
write!(w, "</code>")?;
2942-
render_stability_since_raw(w, item.stable_since(), outer_version)?;
2942+
if let Some(l) = (Item { cx, item }).src_href() {
2943+
write!(w, "</span><span class='out-of-band'>")?;
2944+
write!(w, "<div class='ghost'></div>")?;
2945+
render_stability_since_raw(w, item.stable_since(), outer_version)?;
2946+
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2947+
l, "goto source code")?;
2948+
} else {
2949+
render_stability_since_raw(w, item.stable_since(), outer_version)?;
2950+
}
29432951
write!(w, "</span></h4>\n")?;
29442952
}
29452953
}

src/librustdoc/html/static/rustdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ h3.impl > .out-of-band {
297297
font-size: 21px;
298298
}
299299

300+
h4.method > .out-of-band {
301+
font-size: 19px;
302+
}
303+
300304
h4 > code, h3 > code, .invisible > code {
301305
position: inherit;
302306
}

0 commit comments

Comments
 (0)