@@ -86,7 +86,11 @@ crate type NameDoc = (String, Option<String>);
8686
8787crate fn ensure_trailing_slash ( v : & str ) -> impl fmt:: Display + ' _ {
8888 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+ }
9094 } )
9195}
9296
@@ -1194,6 +1198,16 @@ fn write_minify(
11941198 }
11951199}
11961200
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+
11971211#[ derive( Debug , Eq , PartialEq , Hash ) ]
11981212struct ItemEntry {
11991213 url : String ,
@@ -1706,13 +1720,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
17061720 // this page, and this link will be auto-clicked. The `id` attribute is
17071721 // used to find the link to auto-click.
17081722 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) ;
17161724 }
17171725
17181726 write ! ( buf, "</span>" ) ; // out-of-band
@@ -1942,7 +1950,11 @@ fn document_stability(
19421950}
19431951
19441952fn 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+ }
19461958}
19471959
19481960fn document_non_exhaustive ( w : & mut Buffer , item : & clean:: Item ) {
@@ -3693,13 +3705,7 @@ fn render_impl(
36933705 StabilityLevel :: Unstable { .. } => None ,
36943706 } ) ;
36953707 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) ;
37033709 write ! ( w, "</h3>" ) ;
37043710
37053711 if trait_. is_some ( ) {
@@ -3765,13 +3771,7 @@ fn render_impl(
37653771 render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl ) ;
37663772 write ! ( w, "</code>" ) ;
37673773 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) ;
37753775 write ! ( w, "</h4>" ) ;
37763776 }
37773777 }
@@ -3787,13 +3787,7 @@ fn render_impl(
37873787 assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) , "" ) ;
37883788 write ! ( w, "</code>" ) ;
37893789 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) ;
37973791 write ! ( w, "</h4>" ) ;
37983792 }
37993793 clean:: AssocTypeItem ( ref bounds, ref default) => {
0 commit comments