Skip to content

Commit e7693bc

Browse files
MDBook::build() no longer takes &mut self
1 parent 1018f17 commit e7693bc

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

src/bin/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
9090
b.config.set("output.html.livereload-url", &livereload_url)?;
9191
Ok(b)
9292
})
93-
.and_then(|mut b| b.build());
93+
.and_then(|b| b.build());
9494

9595
if let Err(e) = result {
9696
error!("Unable to load the book");

src/bin/watch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
2222
// Watch command implementation
2323
pub fn execute(args: &ArgMatches) -> Result<()> {
2424
let book_dir = get_book_dir(args);
25-
let mut book = MDBook::load(&book_dir)?;
25+
let book = MDBook::load(&book_dir)?;
2626

2727
if args.is_present("open") {
2828
book.build()?;
@@ -31,7 +31,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
3131

3232
trigger_on_change(&book, |path, book_dir| {
3333
println!("File changed: {:?}\nBuilding book...\n", path);
34-
let result = MDBook::load(&book_dir).and_then(|mut b| b.build());
34+
let result = MDBook::load(&book_dir).and_then(|b| b.build());
3535

3636
if let Err(e) = result {
3737
println!("Error while building: {}", e);

src/book/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl MDBook {
145145
}
146146

147147
/// Tells the renderer to build our book and put it in the build directory.
148-
pub fn build(&mut self) -> Result<()> {
148+
pub fn build(&self) -> Result<()> {
149149
debug!("[fn]: build");
150150

151151
for renderer in &self.renderers {

tests/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
6262
#[test]
6363
fn book_toml_isnt_required() {
6464
let temp = TempDir::new("mdbook").unwrap();
65-
let mut md = MDBook::init(temp.path()).build().unwrap();
65+
let md = MDBook::init(temp.path()).build().unwrap();
6666

6767
let _ = fs::remove_file(temp.path().join("book.toml"));
6868

tests/rendered_output.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use mdbook::utils::fs::file_to_string;
2222
use mdbook::config::Config;
2323
use mdbook::MDBook;
2424

25-
2625
const BOOK_ROOT: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/dummy_book");
2726
const TOC_TOP_LEVEL: &[&'static str] = &[
2827
"1. First Chapter",
@@ -36,15 +35,15 @@ const TOC_SECOND_LEVEL: &[&'static str] = &["1.1. Nested Chapter"];
3635
#[test]
3736
fn build_the_dummy_book() {
3837
let temp = DummyBook::new().build().unwrap();
39-
let mut md = MDBook::load(temp.path()).unwrap();
38+
let md = MDBook::load(temp.path()).unwrap();
4039

4140
md.build().unwrap();
4241
}
4342

4443
#[test]
4544
fn by_default_mdbook_generates_rendered_content_in_the_book_directory() {
4645
let temp = DummyBook::new().build().unwrap();
47-
let mut md = MDBook::load(temp.path()).unwrap();
46+
let md = MDBook::load(temp.path()).unwrap();
4847

4948
assert!(!temp.path().join("book").exists());
5049
md.build().unwrap();
@@ -56,7 +55,7 @@ fn by_default_mdbook_generates_rendered_content_in_the_book_directory() {
5655
#[test]
5756
fn make_sure_bottom_level_files_contain_links_to_chapters() {
5857
let temp = DummyBook::new().build().unwrap();
59-
let mut md = MDBook::load(temp.path()).unwrap();
58+
let md = MDBook::load(temp.path()).unwrap();
6059
md.build().unwrap();
6160

6261
let dest = temp.path().join("book");
@@ -78,7 +77,7 @@ fn make_sure_bottom_level_files_contain_links_to_chapters() {
7877
#[test]
7978
fn check_correct_cross_links_in_nested_dir() {
8079
let temp = DummyBook::new().build().unwrap();
81-
let mut md = MDBook::load(temp.path()).unwrap();
80+
let md = MDBook::load(temp.path()).unwrap();
8281
md.build().unwrap();
8382

8483
let first = temp.path().join("book").join("first");
@@ -115,7 +114,7 @@ fn check_correct_cross_links_in_nested_dir() {
115114
#[test]
116115
fn rendered_code_has_playpen_stuff() {
117116
let temp = DummyBook::new().build().unwrap();
118-
let mut md = MDBook::load(temp.path()).unwrap();
117+
let md = MDBook::load(temp.path()).unwrap();
119118
md.build().unwrap();
120119

121120
let nested = temp.path().join("book/first/nested.html");
@@ -138,7 +137,7 @@ fn chapter_content_appears_in_rendered_document() {
138137
];
139138

140139
let temp = DummyBook::new().build().unwrap();
141-
let mut md = MDBook::load(temp.path()).unwrap();
140+
let md = MDBook::load(temp.path()).unwrap();
142141
md.build().unwrap();
143142

144143
let destination = temp.path().join("book");
@@ -149,7 +148,6 @@ fn chapter_content_appears_in_rendered_document() {
149148
}
150149
}
151150

152-
153151
/// Apply a series of predicates to some root predicate, where each
154152
/// successive predicate is the descendant of the last one. Similar to how you
155153
/// might do `ul.foo li a` in CSS to access all anchor tags in the `foo` list.
@@ -162,7 +160,6 @@ macro_rules! descendants {
162160
};
163161
}
164162

165-
166163
/// Make sure that all `*.md` files (excluding `SUMMARY.md`) were rendered
167164
/// and placed in the `book` directory with their extensions set to `*.html`.
168165
#[test]
@@ -286,7 +283,7 @@ fn create_missing_file_with_config() {
286283
#[test]
287284
fn able_to_include_rust_files_in_chapters() {
288285
let temp = DummyBook::new().build().unwrap();
289-
let mut md = MDBook::load(temp.path()).unwrap();
286+
let md = MDBook::load(temp.path()).unwrap();
290287
md.build().unwrap();
291288

292289
let second = temp.path().join("book/second.html");
@@ -302,7 +299,7 @@ fn able_to_include_rust_files_in_chapters() {
302299
fn example_book_can_build() {
303300
let example_book_dir = dummy_book::new_copy_of_example_book().unwrap();
304301

305-
let mut md = MDBook::load(example_book_dir.path()).unwrap();
302+
let md = MDBook::load(example_book_dir.path()).unwrap();
306303

307304
md.build().unwrap();
308305
}

0 commit comments

Comments
 (0)