using rustfmt 0.99.2-nightly
This commit is contained in:
Matt Ickstadt 2018-08-21 10:58:44 -05:00
parent 3e89e8b1bd
commit 3688f73052
10 changed files with 42 additions and 31 deletions

View File

@ -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"),

View File

@ -475,8 +475,7 @@ fn stringify_events(events: Vec<Event>) -> 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<u32>` with

View File

@ -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

View File

@ -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)'",
)

View File

@ -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");

View File

@ -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

View File

@ -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) {

View File

@ -45,7 +45,11 @@ impl Target {
}
}
fn find_chapter(ctx: &Context, rc: &mut RenderContext, target: Target) -> Result<Option<StringMap>, RenderError> {
fn find_chapter(
ctx: &Context,
rc: &mut RenderContext,
target: Target,
) -> Result<Option<StringMap>, 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)? {

View File

@ -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

View File

@ -33,8 +33,7 @@ pub fn normalize_id(content: &str) -> String {
} else {
None
}
})
.collect::<String>();
}).collect::<String>();
// 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`.