From 3688f73052454bf510a5acc85cf55aae450c6e46 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Tue, 21 Aug 2018 10:58:44 -0500 Subject: [PATCH] rustfmt using rustfmt 0.99.2-nightly --- src/book/book.rs | 3 +-- src/book/summary.rs | 3 +-- src/cmd/build.rs | 6 ++--- src/cmd/clean.rs | 3 +-- src/cmd/serve.rs | 6 ++--- src/cmd/watch.rs | 6 ++--- src/renderer/html_handlebars/hbs_renderer.rs | 9 +++----- .../html_handlebars/helpers/navigation.rs | 22 ++++++++++++++++--- src/renderer/html_handlebars/helpers/toc.rs | 9 +++++++- src/utils/mod.rs | 6 ++--- 10 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/book/book.rs b/src/book/book.rs index 25bd63b8..e4c631ef 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -481,8 +481,7 @@ And here is some \ .filter_map(|i| match *i { BookItem::Chapter(ref ch) => Some(ch.name.clone()), _ => None, - }) - .collect(); + }).collect(); let should_be: Vec<_> = vec![ String::from("Chapter 1"), String::from("Hello World"), diff --git a/src/book/summary.rs b/src/book/summary.rs index 9e2ddd2d..f721fbee 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -475,8 +475,7 @@ fn stringify_events(events: Vec) -> String { .filter_map(|t| match t { Event::Text(text) => Some(text.into_owned()), _ => None, - }) - .collect() + }).collect() } /// A section number like "1.2.3", basically just a newtype'd `Vec` with diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 350a3ece..f4c0cecd 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -10,12 +10,10 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ (If omitted, uses build.build-dir from book.toml or defaults to ./book)'", - ) - .arg_from_usage( + ).arg_from_usage( "[dir] 'Root directory for the book{n}\ (Defaults to the Current Directory when omitted)'", - ) - .arg_from_usage("-o, --open 'Opens the compiled book in a web browser'") + ).arg_from_usage("-o, --open 'Opens the compiled book in a web browser'") } // Build command implementation diff --git a/src/cmd/clean.rs b/src/cmd/clean.rs index 9bcf3f20..09c8d912 100644 --- a/src/cmd/clean.rs +++ b/src/cmd/clean.rs @@ -11,8 +11,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ (If omitted, uses build.build-dir from book.toml or defaults to ./book)'", - ) - .arg_from_usage( + ).arg_from_usage( "[dir] 'Root directory for the book{n}\ (Defaults to the Current Directory when omitted)'", ) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 421c37e1..aefd21ed 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -122,10 +122,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let result = MDBook::load(&book_dir) .and_then(|mut b| { - b.config.set("output.html.livereload-url", &livereload_url)?; + b.config + .set("output.html.livereload-url", &livereload_url)?; Ok(b) - }) - .and_then(|b| b.build()); + }).and_then(|b| b.build()); if let Err(e) = result { error!("Unable to load the book"); diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 0f809251..1aaa633c 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -17,12 +17,10 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { .arg_from_usage( "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\ (If omitted, uses build.build-dir from book.toml or defaults to ./book)'", - ) - .arg_from_usage( + ).arg_from_usage( "[dir] 'Root directory for the book{n}\ (Defaults to the Current Directory when omitted)'", - ) - .arg_from_usage("-o, --open 'Open the compiled book in a web browser'") + ).arg_from_usage("-o, --open 'Open the compiled book in a web browser'") } // Watch command implementation diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index d29707b4..3f87ba4d 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -500,8 +500,7 @@ fn build_header_links(html: &str) -> String { .expect("Regex should ensure we only ever get numbers here"); 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 @@ -552,8 +551,7 @@ fn fix_code_blocks(html: &str) -> String { classes = classes, after = after ) - }) - .into_owned() + }).into_owned() } fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String { @@ -589,8 +587,7 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String { // not language-rust, so no-op text.to_owned() } - }) - .into_owned() + }).into_owned() } fn partition_source(s: &str) -> (String, String) { diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index 77d3b01b..dc84d0da 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -45,7 +45,11 @@ impl Target { } } -fn find_chapter(ctx: &Context, rc: &mut RenderContext, target: Target) -> Result, RenderError> { +fn find_chapter( + ctx: &Context, + rc: &mut RenderContext, + target: Target, +) -> Result, RenderError> { debug!("Get data from context"); let chapters = rc.evaluate_absolute(ctx, "chapters", true).and_then(|c| { @@ -132,7 +136,13 @@ fn render( Ok(()) } -pub fn previous(_h: &Helper, r: &Handlebars, ctx: &Context, rc: &mut RenderContext, out: &mut Output) -> Result<(), RenderError> { +pub fn previous( + _h: &Helper, + r: &Handlebars, + ctx: &Context, + rc: &mut RenderContext, + out: &mut Output, +) -> Result<(), RenderError> { trace!("previous (handlebars helper)"); if let Some(previous) = find_chapter(ctx, rc, Target::Previous)? { @@ -142,7 +152,13 @@ pub fn previous(_h: &Helper, r: &Handlebars, ctx: &Context, rc: &mut RenderConte Ok(()) } -pub fn next(_h: &Helper, r: &Handlebars, ctx: &Context, rc: &mut RenderContext, out: &mut Output) -> Result<(), RenderError> { +pub fn next( + _h: &Helper, + r: &Handlebars, + ctx: &Context, + rc: &mut RenderContext, + out: &mut Output, +) -> Result<(), RenderError> { trace!("next (handlebars helper)"); if let Some(next) = find_chapter(ctx, rc, Target::Next)? { diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs index fdec1fe8..190a3470 100644 --- a/src/renderer/html_handlebars/helpers/toc.rs +++ b/src/renderer/html_handlebars/helpers/toc.rs @@ -14,7 +14,14 @@ pub struct RenderToc { } impl HelperDef for RenderToc { - fn call<'reg:'rc, 'rc>(&self, _h: &Helper, _: &Handlebars, ctx: &Context, rc: &mut RenderContext, out: &mut Output) -> Result<(), RenderError> { + fn call<'reg: 'rc, 'rc>( + &self, + _h: &Helper, + _: &Handlebars, + ctx: &Context, + rc: &mut RenderContext, + out: &mut Output, + ) -> Result<(), RenderError> { // get value from context data // rc.get_path() is current json parent path, you should always use it like this // param is the key of value you want to display diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3467e72d..d7476a8a 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -33,8 +33,7 @@ pub fn normalize_id(content: &str) -> String { } else { None } - }) - .collect::(); + }).collect::(); // Ensure that the first character is [A-Za-z] if ret .chars() @@ -194,8 +193,7 @@ fn convert_quotes_to_curly(original_text: &str) -> String { preceded_by_whitespace = original_char.is_whitespace(); converted_char - }) - .collect() + }).collect() } /// Prints a "backtrace" of some `Error`.