@@ -1194,6 +1194,16 @@ fn write_minify(
1194
1194
}
1195
1195
}
1196
1196
1197
+ fn write_srclink ( cx : & Context , item : & clean:: Item , buf : & mut Buffer , cache : & Cache ) {
1198
+ if let Some ( l) = cx. src_href ( item, cache) {
1199
+ write ! (
1200
+ buf,
1201
+ "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
1202
+ l, "goto source code"
1203
+ )
1204
+ }
1205
+ }
1206
+
1197
1207
#[ derive( Debug , Eq , PartialEq , Hash ) ]
1198
1208
struct ItemEntry {
1199
1209
url : String ,
@@ -1706,13 +1716,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
1706
1716
// this page, and this link will be auto-clicked. The `id` attribute is
1707
1717
// used to find the link to auto-click.
1708
1718
if cx. shared . include_sources && !item. is_primitive ( ) {
1709
- if let Some ( l) = cx. src_href ( item, cache) {
1710
- write ! (
1711
- buf,
1712
- "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
1713
- l, "goto source code"
1714
- ) ;
1715
- }
1719
+ write_srclink ( cx, item, buf, cache) ;
1716
1720
}
1717
1721
1718
1722
write ! ( buf, "</span>" ) ; // out-of-band
@@ -2624,7 +2628,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2624
2628
write ! ( w, "{}<span class=\" loading-content\" >Loading content...</span>" , extra_content)
2625
2629
}
2626
2630
2627
- fn trait_item ( w : & mut Buffer , cx : & Context , m : & clean:: Item , t : & clean:: Item ) {
2631
+ fn trait_item ( w : & mut Buffer , cx : & Context , m : & clean:: Item , t : & clean:: Item , cache : & Cache ) {
2628
2632
let name = m. name . as_ref ( ) . unwrap ( ) ;
2629
2633
info ! ( "Documenting {} on {}" , name, t. name. as_deref( ) . unwrap_or_default( ) ) ;
2630
2634
let item_type = m. type_ ( ) ;
@@ -2633,6 +2637,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2633
2637
render_assoc_item ( w, m, AssocItemLink :: Anchor ( Some ( & id) ) , ItemType :: Impl ) ;
2634
2638
write ! ( w, "</code>" ) ;
2635
2639
render_stability_since ( w, m, t) ;
2640
+ write_srclink ( cx, m, w, cache) ;
2636
2641
write ! ( w, "</h3>" ) ;
2637
2642
document ( w, cx, m, Some ( t) ) ;
2638
2643
}
@@ -2644,8 +2649,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2644
2649
"Associated Types" ,
2645
2650
"<div class=\" methods\" >" ,
2646
2651
) ;
2647
- for t in & types {
2648
- trait_item ( w, cx, * t, it) ;
2652
+ for t in types {
2653
+ trait_item ( w, cx, t, it, cache ) ;
2649
2654
}
2650
2655
write_loading_content ( w, "</div>" ) ;
2651
2656
}
@@ -2657,8 +2662,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2657
2662
"Associated Constants" ,
2658
2663
"<div class=\" methods\" >" ,
2659
2664
) ;
2660
- for t in & consts {
2661
- trait_item ( w, cx, * t, it) ;
2665
+ for t in consts {
2666
+ trait_item ( w, cx, t, it, cache ) ;
2662
2667
}
2663
2668
write_loading_content ( w, "</div>" ) ;
2664
2669
}
@@ -2671,8 +2676,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2671
2676
"Required methods" ,
2672
2677
"<div class=\" methods\" >" ,
2673
2678
) ;
2674
- for m in & required {
2675
- trait_item ( w, cx, * m, it) ;
2679
+ for m in required {
2680
+ trait_item ( w, cx, m, it, cache ) ;
2676
2681
}
2677
2682
write_loading_content ( w, "</div>" ) ;
2678
2683
}
@@ -2683,8 +2688,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2683
2688
"Provided methods" ,
2684
2689
"<div class=\" methods\" >" ,
2685
2690
) ;
2686
- for m in & provided {
2687
- trait_item ( w, cx, * m, it) ;
2691
+ for m in provided {
2692
+ trait_item ( w, cx, m, it, cache ) ;
2688
2693
}
2689
2694
write_loading_content ( w, "</div>" ) ;
2690
2695
}
@@ -3693,13 +3698,7 @@ fn render_impl(
3693
3698
StabilityLevel :: Unstable { .. } => None ,
3694
3699
} ) ;
3695
3700
render_stability_since_raw ( w, since. as_deref ( ) , outer_version) ;
3696
- if let Some ( l) = cx. src_href ( & i. impl_item , cache) {
3697
- write ! (
3698
- w,
3699
- "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
3700
- l, "goto source code"
3701
- ) ;
3702
- }
3701
+ write_srclink ( cx, & i. impl_item , w, cache) ;
3703
3702
write ! ( w, "</h3>" ) ;
3704
3703
3705
3704
if trait_. is_some ( ) {
@@ -3765,13 +3764,7 @@ fn render_impl(
3765
3764
render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
3766
3765
write ! ( w, "</code>" ) ;
3767
3766
render_stability_since_raw ( w, item. stable_since ( ) . as_deref ( ) , outer_version) ;
3768
- if let Some ( l) = cx. src_href ( item, cache) {
3769
- write ! (
3770
- w,
3771
- "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
3772
- l, "goto source code"
3773
- ) ;
3774
- }
3767
+ write_srclink ( cx, item, w, cache) ;
3775
3768
write ! ( w, "</h4>" ) ;
3776
3769
}
3777
3770
}
@@ -3787,13 +3780,7 @@ fn render_impl(
3787
3780
assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) , "" ) ;
3788
3781
write ! ( w, "</code>" ) ;
3789
3782
render_stability_since_raw ( w, item. stable_since ( ) . as_deref ( ) , outer_version) ;
3790
- if let Some ( l) = cx. src_href ( item, cache) {
3791
- write ! (
3792
- w,
3793
- "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
3794
- l, "goto source code"
3795
- ) ;
3796
- }
3783
+ write_srclink ( cx, item, w, cache) ;
3797
3784
write ! ( w, "</h4>" ) ;
3798
3785
}
3799
3786
clean:: AssocTypeItem ( ref bounds, ref default) => {
0 commit comments