Passed through rustfmt

This commit is contained in:
Sytse Reitsma 2019-04-17 20:57:46 +02:00
parent 261207064e
commit dfaf7c7558
1 changed files with 36 additions and 26 deletions

View File

@ -36,7 +36,8 @@ impl HtmlHandlebars {
bail!(ErrorKind::ReservedFilenameError(ch.path.clone())); bail!(ErrorKind::ReservedFilenameError(ch.path.clone()));
}; };
let path = ch.path let path = ch
.path
.to_str() .to_str()
.chain_err(|| "Could not convert path to str")?; .chain_err(|| "Could not convert path to str")?;
@ -45,7 +46,11 @@ impl HtmlHandlebars {
let string_path = ch.path.parent().unwrap().display().to_string(); let string_path = ch.path.parent().unwrap().display().to_string();
let fixed_content = utils::render_markdown_with_base(&ch.content, ctx.html_config.curly_quotes, &string_path); let fixed_content = utils::render_markdown_with_base(
&ch.content,
ctx.html_config.curly_quotes,
&string_path,
);
print_content.push_str(&fixed_content); print_content.push_str(&fixed_content);
// Update the context with data for this file // Update the context with data for this file
@ -511,7 +516,8 @@ fn build_header_links(html: &str) -> String {
.expect("Regex should ensure we only ever get numbers here"); .expect("Regex should ensure we only ever get numbers here");
wrap_header_with_link(level, &caps[2], &mut id_counter) wrap_header_with_link(level, &caps[2], &mut id_counter)
}).into_owned() })
.into_owned()
} }
/// Wraps a single header tag with a link, making sure each tag gets its own /// Wraps a single header tag with a link, making sure each tag gets its own
@ -562,7 +568,8 @@ fn fix_code_blocks(html: &str) -> String {
classes = classes, classes = classes,
after = after after = after
) )
}).into_owned() })
.into_owned()
} }
fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String { fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
@ -598,7 +605,8 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
// not language-rust, so no-op // not language-rust, so no-op
text.to_owned() text.to_owned()
} }
}).into_owned() })
.into_owned()
} }
fn partition_source(s: &str) -> (String, String) { fn partition_source(s: &str) -> (String, String) {
@ -635,7 +643,6 @@ mod tests {
use super::*; use super::*;
use book::Chapter; use book::Chapter;
#[test] #[test]
fn original_build_header_links() { fn original_build_header_links() {
let inputs = vec![ let inputs = vec![
@ -678,7 +685,6 @@ mod tests {
impl<'a> PathTestContext<'a> { impl<'a> PathTestContext<'a> {
pub fn new(path: String, dummy_handlebars: &'a Handlebars) -> PathTestContext<'a> { pub fn new(path: String, dummy_handlebars: &'a Handlebars) -> PathTestContext<'a> {
PathTestContext { PathTestContext {
render_context: RenderItemContext { render_context: RenderItemContext {
handlebars: dummy_handlebars, handlebars: dummy_handlebars,
@ -687,14 +693,12 @@ mod tests {
is_index: false, is_index: false,
html_config: HtmlConfig { html_config: HtmlConfig {
..Default::default() ..Default::default()
}
}, },
item : BookItem::Chapter( },
Chapter { item: BookItem::Chapter(Chapter {
path: PathBuf::from(path), path: PathBuf::from(path),
..Default::default() ..Default::default()
} }),
),
} }
} }
} }
@ -707,7 +711,10 @@ mod tests {
let mut content = String::new(); let mut content = String::new();
match html_handlebars.render_item(&ctx.item, ctx.render_context, &mut content) { match html_handlebars.render_item(&ctx.item, ctx.render_context, &mut content) {
Ok(_) => assert!(false, "Expected a failure, because print.md is a reserved filename"), Ok(_) => assert!(
false,
"Expected a failure, because print.md is a reserved filename"
),
Err(error) => assert_eq!(error.to_string(), "print.md is reserved for internal use"), Err(error) => assert_eq!(error.to_string(), "print.md is reserved for internal use"),
}; };
} }
@ -728,7 +735,10 @@ mod tests {
let mut content = String::new(); let mut content = String::new();
match html_handlebars.render_item(&ctx.item, ctx.render_context, &mut content) { match html_handlebars.render_item(&ctx.item, ctx.render_context, &mut content) {
Ok(_) => assert!(false, "Expected a failure in PathBuf::to_str (for BookItem::Chapter::path)"), Ok(_) => assert!(
false,
"Expected a failure in PathBuf::to_str (for BookItem::Chapter::path)"
),
Err(error) => assert_eq!(error.to_string(), "Could not convert path to str"), Err(error) => assert_eq!(error.to_string(), "Could not convert path to str"),
}; };
} }