Skip to content

Commit 406b325

Browse files
fix usage of newly stablized inner_deref/as_deref
1 parent 6d6e540 commit 406b325

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/cmd/serve.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
8383
.config
8484
.get("output.html.input-404")
8585
.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);
8889

8990
// A channel used to broadcast to any websockets to reload when a file changes.
9091
let (tx, _rx) = tokio::sync::broadcast::channel::<Message>(100);

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ mod tests {
10231023
let html_config = got.html_config().unwrap();
10241024
assert_eq!(html_config.input_404, None);
10251025
assert_eq!(
1026-
&get_404_output_file(html_config.input_404.as_deref()),
1026+
&get_404_output_file(&html_config.input_404),
10271027
"404.html"
10281028
);
10291029
}
@@ -1040,7 +1040,7 @@ mod tests {
10401040
let html_config = got.html_config().unwrap();
10411041
assert_eq!(html_config.input_404, Some("missing.md".to_string()));
10421042
assert_eq!(
1043-
&get_404_output_file(html_config.input_404.as_deref()),
1043+
&get_404_output_file(&html_config.input_404),
10441044
"missing.html"
10451045
);
10461046
}

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl HtmlHandlebars {
152152
let rendered = handlebars.render("index", &data_404)?;
153153

154154
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);
156156
utils::fs::write_file(&destination, output_file, rendered.as_bytes())?;
157157
debug!("Creating 404.html ✓");
158158
Ok(())

src/utils/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ pub fn copy_files_except_ext(
177177
Ok(())
178178
}
179179

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")
182182
}
183183

184184
#[cfg(test)]

0 commit comments

Comments
 (0)