Skip to content

Commit

Permalink
Merge pull request #1215 from ehuss/block-cleanup
Browse files Browse the repository at this point in the history
Remove some unnecessary blocks.
  • Loading branch information
ehuss authored May 10, 2020
2 parents 578e4da + 6038af2 commit e8d4bc5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
24 changes: 10 additions & 14 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("");

title = match book_title {
"" => ch.name.clone(),
_ => ch.name.clone() + " - " + book_title,
}
}
let book_title = ctx
.data
.get("book_title")
.and_then(serde_json::Value::as_str)
.unwrap_or("");

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));
Expand Down
18 changes: 8 additions & 10 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down

0 comments on commit e8d4bc5

Please sign in to comment.