@@ -86,7 +86,11 @@ crate type NameDoc = (String, Option<String>);
86
86
87
87
crate fn ensure_trailing_slash ( v : & str ) -> impl fmt:: Display + ' _ {
88
88
crate :: html:: format:: display_fn ( move |f| {
89
- if !v. ends_with ( '/' ) && !v. is_empty ( ) { write ! ( f, "{}/" , v) } else { write ! ( f, "{}" , v) }
89
+ if !v. ends_with ( '/' ) && !v. is_empty ( ) {
90
+ write ! ( f, "{}/" , v)
91
+ } else {
92
+ write ! ( f, "{}" , v)
93
+ }
90
94
} )
91
95
}
92
96
@@ -1194,6 +1198,16 @@ fn write_minify(
1194
1198
}
1195
1199
}
1196
1200
1201
+ fn write_srclink ( cx : & Context , item : & clean:: Item , buf : & mut Buffer , cache : & Cache ) {
1202
+ if let Some ( l) = cx. src_href ( item, cache) {
1203
+ write ! (
1204
+ buf,
1205
+ "<a class=\" srclink\" href=\" {}\" title=\" {}\" >[src]</a>" ,
1206
+ l, "goto source code"
1207
+ )
1208
+ }
1209
+ }
1210
+
1197
1211
#[ derive( Debug , Eq , PartialEq , Hash ) ]
1198
1212
struct ItemEntry {
1199
1213
url : String ,
@@ -1706,13 +1720,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
1706
1720
// this page, and this link will be auto-clicked. The `id` attribute is
1707
1721
// used to find the link to auto-click.
1708
1722
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
- }
1723
+ write_srclink ( cx, item, buf, cache) ;
1716
1724
}
1717
1725
1718
1726
write ! ( buf, "</span>" ) ; // out-of-band
@@ -1942,7 +1950,11 @@ fn document_stability(
1942
1950
}
1943
1951
1944
1952
fn document_non_exhaustive_header ( item : & clean:: Item ) -> & str {
1945
- if item. is_non_exhaustive ( ) { " (Non-exhaustive)" } else { "" }
1953
+ if item. is_non_exhaustive ( ) {
1954
+ " (Non-exhaustive)"
1955
+ } else {
1956
+ ""
1957
+ }
1946
1958
}
1947
1959
1948
1960
fn document_non_exhaustive ( w : & mut Buffer , item : & clean:: Item ) {
@@ -3693,13 +3705,7 @@ fn render_impl(
3693
3705
StabilityLevel :: Unstable { .. } => None ,
3694
3706
} ) ;
3695
3707
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
- }
3708
+ write_srclink ( cx, & i. impl_item , w, cache) ;
3703
3709
write ! ( w, "</h3>" ) ;
3704
3710
3705
3711
if trait_. is_some ( ) {
@@ -3765,13 +3771,7 @@ fn render_impl(
3765
3771
render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
3766
3772
write ! ( w, "</code>" ) ;
3767
3773
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
- }
3774
+ write_srclink ( cx, item, w, cache) ;
3775
3775
write ! ( w, "</h4>" ) ;
3776
3776
}
3777
3777
}
@@ -3787,13 +3787,7 @@ fn render_impl(
3787
3787
assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) , "" ) ;
3788
3788
write ! ( w, "</code>" ) ;
3789
3789
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
- }
3790
+ write_srclink ( cx, item, w, cache) ;
3797
3791
write ! ( w, "</h4>" ) ;
3798
3792
}
3799
3793
clean:: AssocTypeItem ( ref bounds, ref default) => {
0 commit comments