From d7df832cceaaa07d1546d05b5474b3cb70190e77 Mon Sep 17 00:00:00 2001 From: Manuel Woelker Date: Wed, 10 Jun 2020 15:33:09 +0200 Subject: [PATCH] fix test and formatting --- src/cmd/serve.rs | 2 +- src/config.rs | 10 ++-------- src/utils/fs.rs | 5 ++++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index e9209b63..0940938f 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -83,7 +83,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { .config .get("output.html.input-404") .map(toml::Value::as_str) - .flatten() + .and_then(std::convert::identity) // flatten .map(ToString::to_string); let file_404 = get_404_output_file(&input_404); diff --git a/src/config.rs b/src/config.rs index cbcf3e91..8a7744eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1022,10 +1022,7 @@ mod tests { let got = Config::from_str(src).unwrap(); let html_config = got.html_config().unwrap(); assert_eq!(html_config.input_404, None); - assert_eq!( - &get_404_output_file(&html_config.input_404), - "404.html" - ); + assert_eq!(&get_404_output_file(&html_config.input_404), "404.html"); } #[test] @@ -1039,9 +1036,6 @@ mod tests { let got = Config::from_str(src).unwrap(); 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), - "missing.html" - ); + assert_eq!(&get_404_output_file(&html_config.input_404), "missing.html"); } } diff --git a/src/utils/fs.rs b/src/utils/fs.rs index a1bea133..7a7aa63a 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -178,7 +178,10 @@ pub fn copy_files_except_ext( } pub fn get_404_output_file(input_404: &Option) -> String { - input_404.as_ref().unwrap_or(&"404.md".to_string()).replace(".md", ".html") + input_404 + .as_ref() + .unwrap_or(&"404.md".to_string()) + .replace(".md", ".html") } #[cfg(test)]