File tree Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -83,8 +83,9 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
83
83
. config
84
84
. get ( "output.html.input-404" )
85
85
. map ( toml:: Value :: as_str)
86
- . flatten ( ) ;
87
- let file_404 = get_404_output_file ( input_404) ;
86
+ . flatten ( )
87
+ . map ( ToString :: to_string) ;
88
+ let file_404 = get_404_output_file ( & input_404) ;
88
89
89
90
// A channel used to broadcast to any websockets to reload when a file changes.
90
91
let ( tx, _rx) = tokio:: sync:: broadcast:: channel :: < Message > ( 100 ) ;
Original file line number Diff line number Diff line change @@ -1023,7 +1023,7 @@ mod tests {
1023
1023
let html_config = got. html_config ( ) . unwrap ( ) ;
1024
1024
assert_eq ! ( html_config. input_404, None ) ;
1025
1025
assert_eq ! (
1026
- & get_404_output_file( html_config. input_404. as_deref ( ) ) ,
1026
+ & get_404_output_file( & html_config. input_404) ,
1027
1027
"404.html"
1028
1028
) ;
1029
1029
}
@@ -1040,7 +1040,7 @@ mod tests {
1040
1040
let html_config = got. html_config ( ) . unwrap ( ) ;
1041
1041
assert_eq ! ( html_config. input_404, Some ( "missing.md" . to_string( ) ) ) ;
1042
1042
assert_eq ! (
1043
- & get_404_output_file( html_config. input_404. as_deref ( ) ) ,
1043
+ & get_404_output_file( & html_config. input_404) ,
1044
1044
"missing.html"
1045
1045
) ;
1046
1046
}
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ impl HtmlHandlebars {
152
152
let rendered = handlebars. render ( "index" , & data_404) ?;
153
153
154
154
let rendered = self . post_process ( rendered, & html_config. playpen , ctx. config . rust . edition ) ;
155
- let output_file = get_404_output_file ( html_config. input_404 . as_deref ( ) ) ;
155
+ let output_file = get_404_output_file ( & html_config. input_404 ) ;
156
156
utils:: fs:: write_file ( & destination, output_file, rendered. as_bytes ( ) ) ?;
157
157
debug ! ( "Creating 404.html ✓" ) ;
158
158
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -177,8 +177,8 @@ pub fn copy_files_except_ext(
177
177
Ok ( ( ) )
178
178
}
179
179
180
- pub fn get_404_output_file ( input_404 : Option < & str > ) -> String {
181
- input_404. unwrap_or ( "404.md" ) . replace ( ".md" , ".html" )
180
+ pub fn get_404_output_file ( input_404 : & Option < String > ) -> String {
181
+ input_404. as_ref ( ) . unwrap_or ( & "404.md" . to_string ( ) ) . replace ( ".md" , ".html" )
182
182
}
183
183
184
184
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments