@@ -2253,6 +2253,18 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2253
2253
document ( w, cx, it)
2254
2254
}
2255
2255
2256
+ fn implementor2item < ' a > ( cache : & ' a Cache , imp : & Implementor ) -> Option < & ' a clean:: Item > {
2257
+ if let Some ( t_did) = imp. impl_ . for_ . def_id ( ) {
2258
+ if let Some ( impl_item) = cache. impls . get ( & t_did) . and_then ( |i| i. iter ( )
2259
+ . find ( |i| i. impl_item . def_id == imp. def_id ) )
2260
+ {
2261
+ let i = & impl_item. impl_item ;
2262
+ return Some ( i) ;
2263
+ }
2264
+ }
2265
+ None
2266
+ }
2267
+
2256
2268
fn item_trait ( w : & mut fmt:: Formatter , cx : & Context , it : & clean:: Item ,
2257
2269
t : & clean:: Trait ) -> fmt:: Result {
2258
2270
let mut bounds = String :: new ( ) ;
@@ -2463,27 +2475,30 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2463
2475
" ) ?;
2464
2476
2465
2477
for implementor in foreign {
2466
- // need to get from a clean::Impl to a clean::Item so i can use render_impl
2467
- if let Some ( t_did) = implementor. impl_ . for_ . def_id ( ) {
2468
- if let Some ( impl_item) = cache. impls . get ( & t_did) . and_then ( |i| i. iter ( )
2469
- . find ( |i| i. impl_item . def_id == implementor. def_id ) )
2470
- {
2471
- let i = & impl_item. impl_item ;
2472
- let impl_ = Impl { impl_item : i. clone ( ) } ;
2473
- let assoc_link = AssocItemLink :: GotoSource (
2474
- i. def_id , & implementor. impl_ . provided_trait_methods
2475
- ) ;
2476
- render_impl ( w, cx, & impl_, assoc_link,
2477
- RenderMode :: Normal , i. stable_since ( ) , false ) ?;
2478
- }
2478
+ if let Some ( i) = implementor2item ( & cache, implementor) {
2479
+ let impl_ = Impl { impl_item : i. clone ( ) } ;
2480
+ let assoc_link = AssocItemLink :: GotoSource (
2481
+ i. def_id , & implementor. impl_ . provided_trait_methods
2482
+ ) ;
2483
+ render_impl ( w, cx, & impl_, assoc_link,
2484
+ RenderMode :: Normal , i. stable_since ( ) , false ) ?;
2479
2485
}
2480
2486
}
2481
2487
}
2482
2488
2483
2489
write ! ( w, "{}" , impl_header) ?;
2484
2490
2485
2491
for implementor in local {
2486
- 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>" ) ?;
2487
2502
// If there's already another implementor that has the same abbridged name, use the
2488
2503
// full path, for example in `std::iter::ExactSizeIterator`
2489
2504
let use_absolute = match implementor. impl_ . for_ {
0 commit comments