From 6038af292fe02b57c5a4cb600fcafb703a01b98d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 10 May 2020 09:23:40 -0700 Subject: [PATCH] Remove some unnecessary blocks. --- src/renderer/html_handlebars/hbs_renderer.rs | 22 ++++++++------------ src/renderer/mod.rs | 18 +++++++--------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 5335247d..80226374 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -57,20 +57,16 @@ impl HtmlHandlebars { bail!(ErrorKind::ReservedFilenameError(path.clone())); }; - // Non-lexical lifetimes needed :'( - let title: String; - { - let book_title = ctx - .data - .get("book_title") - .and_then(serde_json::Value::as_str) - .unwrap_or(""); + let book_title = ctx + .data + .get("book_title") + .and_then(serde_json::Value::as_str) + .unwrap_or(""); - title = match book_title { - "" => ch.name.clone(), - _ => ch.name.clone() + " - " + book_title, - } - } + let title = match book_title { + "" => ch.name.clone(), + _ => ch.name.clone() + " - " + book_title, + }; ctx.data.insert("path".to_owned(), json!(path)); ctx.data.insert("content".to_owned(), json!(content)); diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 59fa8b9e..abe11ba3 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -204,18 +204,16 @@ impl Renderer for CmdRenderer { Err(e) => return self.handle_render_command_error(ctx, e), }; - { - let mut stdin = child.stdin.take().expect("Child has stdin"); - if let Err(e) = serde_json::to_writer(&mut stdin, &ctx) { - // Looks like the backend hung up before we could finish - // sending it the render context. Log the error and keep going - warn!("Error writing the RenderContext to the backend, {}", e); - } - - // explicitly close the `stdin` file handle - drop(stdin); + let mut stdin = child.stdin.take().expect("Child has stdin"); + if let Err(e) = serde_json::to_writer(&mut stdin, &ctx) { + // Looks like the backend hung up before we could finish + // sending it the render context. Log the error and keep going + warn!("Error writing the RenderContext to the backend, {}", e); } + // explicitly close the `stdin` file handle + drop(stdin); + let status = child .wait() .chain_err(|| "Error waiting for the backend to complete")?;