Skip to content

Commit 655961d

Browse files
author
Jason Williams
committed
adding cargo fmt
1 parent fc54175 commit 655961d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use crate::theme::{self, playpen_editor, Theme};
77
use crate::utils;
88

99
use std::borrow::Cow;
10+
use std::collections::hash_map::DefaultHasher;
1011
use std::collections::BTreeMap;
1112
use std::collections::HashMap;
12-
use std::collections::hash_map::DefaultHasher;
13-
use std::hash::Hasher;
1413
use std::fs::{self, OpenOptions};
14+
use std::hash::Hasher;
1515
use std::io::Write;
1616
use std::path::{Path, PathBuf};
1717

@@ -32,15 +32,19 @@ impl HtmlHandlebars {
3232
HtmlHandlebars
3333
}
3434

35-
fn build_service_worker(&self, build_dir: &Path, chapter_files: &Vec<ChapterFile>) -> Result<()> {
35+
fn build_service_worker(
36+
&self,
37+
build_dir: &Path,
38+
chapter_files: &Vec<ChapterFile>,
39+
) -> Result<()> {
3640
let path = build_dir.join("sw.js");
3741
let mut file = OpenOptions::new().append(true).open(path)?;
3842
let mut content = String::from("\nconst chapters = [\n");
3943

40-
for chapter_file in chapter_files {
44+
for chapter_file in chapter_files {
4145
content.push_str(" { url: ");
4246

43-
// Rewrite "/" to point to the current directory
47+
// Rewrite "/" to point to the current directory
4448
// https://rust-lang-nursery.github.io/ => https://rust-lang-nursery.github.io/mdBook/
4549
// location.href is https://rust-lang-nursery.github.io/mdBook/sw.js
4650
// so we remove the sw.js from the end to get the correct path
@@ -52,17 +56,17 @@ impl HtmlHandlebars {
5256
content.push_str("'");
5357
}
5458

55-
content.push_str(", revision: '");
59+
content.push_str(", revision: '");
5660
content.push_str(&chapter_file.revision.to_string());
5761
content.push_str("' },\n");
5862
}
5963

60-
content.push_str("];\n");
64+
content.push_str("];\n");
6165
content.push_str("\nworkbox.precaching.precacheAndRoute(chapters);\n");
6266

63-
file.write(content.as_bytes())?;
67+
file.write(content.as_bytes())?;
6468

65-
Ok(())
69+
Ok(())
6670
}
6771

6872
fn render_item(
@@ -90,9 +94,9 @@ impl HtmlHandlebars {
9094
.to_str()
9195
.chain_err(|| "Could not convert path to str")?;
9296
let filepath = Path::new(&ch.path).with_extension("html");
93-
let filepath_str = filepath.to_str().ok_or_else(|| {
94-
Error::from(format!("Bad file name: {}", filepath.display()))
95-
})?;
97+
let filepath_str = filepath
98+
.to_str()
99+
.ok_or_else(|| Error::from(format!("Bad file name: {}", filepath.display())))?;
96100

97101
// "print.html" is used for the print page.
98102
if ch.path == Path::new("print.md") {

0 commit comments

Comments
 (0)