Skip to content

Commit d7df832

Browse files
fix test and formatting
1 parent 406b325 commit d7df832

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/cmd/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
8383
.config
8484
.get("output.html.input-404")
8585
.map(toml::Value::as_str)
86-
.flatten()
86+
.and_then(std::convert::identity) // flatten
8787
.map(ToString::to_string);
8888
let file_404 = get_404_output_file(&input_404);
8989

src/config.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,7 @@ mod tests {
10221022
let got = Config::from_str(src).unwrap();
10231023
let html_config = got.html_config().unwrap();
10241024
assert_eq!(html_config.input_404, None);
1025-
assert_eq!(
1026-
&get_404_output_file(&html_config.input_404),
1027-
"404.html"
1028-
);
1025+
assert_eq!(&get_404_output_file(&html_config.input_404), "404.html");
10291026
}
10301027

10311028
#[test]
@@ -1039,9 +1036,6 @@ mod tests {
10391036
let got = Config::from_str(src).unwrap();
10401037
let html_config = got.html_config().unwrap();
10411038
assert_eq!(html_config.input_404, Some("missing.md".to_string()));
1042-
assert_eq!(
1043-
&get_404_output_file(&html_config.input_404),
1044-
"missing.html"
1045-
);
1039+
assert_eq!(&get_404_output_file(&html_config.input_404), "missing.html");
10461040
}
10471041
}

src/utils/fs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ pub fn copy_files_except_ext(
178178
}
179179

180180
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")
181+
input_404
182+
.as_ref()
183+
.unwrap_or(&"404.md".to_string())
184+
.replace(".md", ".html")
182185
}
183186

184187
#[cfg(test)]

0 commit comments

Comments
 (0)