Rollup merge of #43509 - QuietMisdreavus:method-src, r=GuillaumeGomez
rustdoc: add [src] links to associated functions inside an impl block While impl blocks currently have a `[src]` link to show the source for the impl block as a whole, individual methods inside that impl block do not. This can pose a problem for structs with a lot of methods, like many in libstd. This change adds little `[src]` links to individual methods that point directly to the function in the bundled source. fixes #12932 
This commit is contained in:
@@ -2962,7 +2962,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
write!(w, "<code>")?;
|
||||
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
|
||||
write!(w, "</code>")?;
|
||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||
if let Some(l) = (Item { cx, item }).src_href() {
|
||||
write!(w, "</span><span class='out-of-band'>")?;
|
||||
write!(w, "<div class='ghost'></div>")?;
|
||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
||||
l, "goto source code")?;
|
||||
} else {
|
||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||
}
|
||||
write!(w, "</span></h4>\n")?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user