mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
fix usage of newly stablized inner_deref/as_deref
This commit is contained in:
parent
6d6e5407a3
commit
406b325c54
4 changed files with 8 additions and 7 deletions
|
@ -83,8 +83,9 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
|||
.config
|
||||
.get("output.html.input-404")
|
||||
.map(toml::Value::as_str)
|
||||
.flatten();
|
||||
let file_404 = get_404_output_file(input_404);
|
||||
.flatten()
|
||||
.map(ToString::to_string);
|
||||
let file_404 = get_404_output_file(&input_404);
|
||||
|
||||
// A channel used to broadcast to any websockets to reload when a file changes.
|
||||
let (tx, _rx) = tokio::sync::broadcast::channel::<Message>(100);
|
||||
|
|
|
@ -1023,7 +1023,7 @@ mod tests {
|
|||
let html_config = got.html_config().unwrap();
|
||||
assert_eq!(html_config.input_404, None);
|
||||
assert_eq!(
|
||||
&get_404_output_file(html_config.input_404.as_deref()),
|
||||
&get_404_output_file(&html_config.input_404),
|
||||
"404.html"
|
||||
);
|
||||
}
|
||||
|
@ -1040,7 +1040,7 @@ mod tests {
|
|||
let html_config = got.html_config().unwrap();
|
||||
assert_eq!(html_config.input_404, Some("missing.md".to_string()));
|
||||
assert_eq!(
|
||||
&get_404_output_file(html_config.input_404.as_deref()),
|
||||
&get_404_output_file(&html_config.input_404),
|
||||
"missing.html"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ impl HtmlHandlebars {
|
|||
let rendered = handlebars.render("index", &data_404)?;
|
||||
|
||||
let rendered = self.post_process(rendered, &html_config.playpen, ctx.config.rust.edition);
|
||||
let output_file = get_404_output_file(html_config.input_404.as_deref());
|
||||
let output_file = get_404_output_file(&html_config.input_404);
|
||||
utils::fs::write_file(&destination, output_file, rendered.as_bytes())?;
|
||||
debug!("Creating 404.html ✓");
|
||||
Ok(())
|
||||
|
|
|
@ -177,8 +177,8 @@ pub fn copy_files_except_ext(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_404_output_file(input_404: Option<&str>) -> String {
|
||||
input_404.unwrap_or("404.md").replace(".md", ".html")
|
||||
pub fn get_404_output_file(input_404: &Option<String>) -> String {
|
||||
input_404.as_ref().unwrap_or(&"404.md".to_string()).replace(".md", ".html")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue