@@ -73,6 +73,18 @@ use minifier;
73
73
/// A pair of name and its optional document.
74
74
pub type NameDoc = ( String , Option < String > ) ;
75
75
76
+ pub struct SlashChecker < ' a > ( pub & ' a str ) ;
77
+
78
+ impl < ' a > Display for SlashChecker < ' a > {
79
+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
80
+ if !self . 0 . ends_with ( "/" ) && !self . 0 . is_empty ( ) {
81
+ write ! ( f, "{}/" , self . 0 )
82
+ } else {
83
+ write ! ( f, "{}" , self . 0 )
84
+ }
85
+ }
86
+ }
87
+
76
88
/// Major driving force in all rustdoc rendering. This contains information
77
89
/// about where in the tree-like hierarchy rendering is occurring and controls
78
90
/// how the current page is being rendered.
@@ -1140,7 +1152,8 @@ themePicker.onblur = handleThemeButtonsBlur;
1140
1152
krates
1141
1153
. iter( )
1142
1154
. map( |s| {
1143
- format!( "<li><a href=\" {}/index.html\" >{}</li>" , s, s)
1155
+ format!( "<li><a href=\" {}index.html\" >{}</li>" ,
1156
+ SlashChecker ( s) , s)
1144
1157
} )
1145
1158
. collect:: <String >( ) ) ;
1146
1159
try_err ! ( layout:: render( & mut w, & cx. shared. layout,
@@ -2074,8 +2087,7 @@ impl Context {
2074
2087
let mut themes = self . shared . themes . clone ( ) ;
2075
2088
let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'></div>" ;
2076
2089
themes. push ( PathBuf :: from ( "settings.css" ) ) ;
2077
- let mut layout = self . shared . layout . clone ( ) ;
2078
- layout. krate = String :: new ( ) ;
2090
+ let layout = self . shared . layout . clone ( ) ;
2079
2091
try_err ! ( layout:: render( & mut w, & layout,
2080
2092
& page, & sidebar, & settings,
2081
2093
self . shared. css_file_extension. is_some( ) ,
@@ -2454,7 +2466,7 @@ impl<'a> fmt::Display for Item<'a> {
2454
2466
2455
2467
fn item_path ( ty : ItemType , name : & str ) -> String {
2456
2468
match ty {
2457
- ItemType :: Module => format ! ( "{}/ index.html" , name) ,
2469
+ ItemType :: Module => format ! ( "{}index.html" , SlashChecker ( name) ) ,
2458
2470
_ => format ! ( "{}.{}.html" , ty. css_class( ) , name) ,
2459
2471
}
2460
2472
}
0 commit comments