Repository: a8m/pb (language: rust)

Issue:
multiple doctests fail to build
```rust
   Doc-tests pbr

running 19 tests
test src/lib.rs -  (line 13) ... ignored
test src/lib.rs -  (line 33) ... ignored
test src/lib.rs -  (line 76) ... ignored
test src/pb.rs - pb::ProgressBar<T>::format (line 163) ... ignored
test src/pb.rs - pb::ProgressBar<T>::message (line 183) ... ignored
test src/multi.rs - multi::MultiBar<T>::on (line 69) ... ok
test src/pb.rs - pb::ProgressBar<T>::add (line 276) ... ok
test src/pb.rs - pb::ProgressBar<T>::set_max_refresh_rate (line 236) ... ignored
test src/multi.rs - multi::MultiBar<T>::create_bar (line 130) ... FAILED
test src/pb.rs - pb::ProgressBar<T>::set_width (line 224) ... ignored
test src/pb.rs - pb::ProgressBar<T>::tick (line 256) ... ignored
test src/pb.rs - pb::ProgressBar<T>::tick_format (line 209) ... ignored
test src/multi.rs - multi::MultiBar<T>::listen (line 174) ... FAILED
test src/multi.rs - multi::MultiBar<T>::println (line 94) ... FAILED
test src/pb.rs - pb::ProgressBar<Stdout>::new (line 72) ... ok
test src/multi.rs - multi::MultiBar<Stdout>::new (line 25) ... FAILED
test src/pb.rs - pb::ProgressBar<T>::on (line 97) ... ok
test src/pb.rs - pb::ProgressBar<T>::set_units (line 148) ... ok
test src/pb.rs - pb::ProgressBar<T>::set (line 292) ... ok

failures:

---- src/multi.rs - multi::MultiBar<T>::create_bar (line 130) stdout ----
	error[E0425]: cannot find value `count1` in this scope
 --> src/multi.rs:136:35
  |
9 | let mut p1 = MultiBar::create_bar(count1);
  |                                   ^^^^^^ not found in this scope

error[E0425]: cannot find value `count2` in this scope
  --> src/multi.rs:140:35
   |
13 | let mut p2 = MultiBar::create_bar(count2);
   |                                   ^^^^^^ not found in this scope

error[E0425]: cannot find value `count3` in this scope
  --> src/multi.rs:144:35
   |
17 | let mut p3 = MultiBar::create_bar(count3);
   |                                   ^^^^^^ not found in this scope

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
 --> src/multi.rs:136:14
  |
9 | let mut p1 = MultiBar::create_bar(count1);
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/multi.rs:140:14
   |
13 | let mut p2 = MultiBar::create_bar(count2);
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/multi.rs:144:14
   |
17 | let mut p3 = MultiBar::create_bar(count3);
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

thread 'src/multi.rs - multi::MultiBar<T>::create_bar (line 130)' panicked at 'couldn't compile the test', librustdoc/test.rs:321:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- src/multi.rs - multi::MultiBar<T>::listen (line 174) stdout ----
	error[E0433]: failed to resolve. Use of undeclared type or module `thread`
  --> src/multi.rs:183:1
   |
12 | thread::spawn(move || {
   | ^^^^^^ Use of undeclared type or module `thread`

thread 'src/multi.rs - multi::MultiBar<T>::listen (line 174)' panicked at 'couldn't compile the test', librustdoc/test.rs:321:13

---- src/multi.rs - multi::MultiBar<T>::println (line 94) stdout ----
	error[E0425]: cannot find value `count` in this scope
 --> src/multi.rs:100:35
  |
9 | let mut p1 = MultiBar::create_bar(count);
  |                                   ^^^^^ not found in this scope

error[E0425]: cannot find value `count` in this scope
  --> src/multi.rs:105:35
   |
14 | let mut p2 = MultiBar::create_bar(count);
   |                                   ^^^^^ not found in this scope

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
 --> src/multi.rs:100:14
  |
9 | let mut p1 = MultiBar::create_bar(count);
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
  --> src/multi.rs:105:14
   |
14 | let mut p2 = MultiBar::create_bar(count);
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters

thread 'src/multi.rs - multi::MultiBar<T>::println (line 94)' panicked at 'couldn't compile the test', librustdoc/test.rs:321:13

---- src/multi.rs - multi::MultiBar<Stdout>::new (line 25) stdout ----
	error[E0433]: failed to resolve. Use of undeclared type or module `Duration`
  --> src/multi.rs:36:23
   |
14 |         thread::sleep(Duration::from_millis(100));
   |                       ^^^^^^^^ Use of undeclared type or module `Duration`

error[E0433]: failed to resolve. Use of undeclared type or module `Duration`
  --> src/multi.rs:48:23
   |
26 |         thread::sleep(Duration::from_millis(100));
   |                       ^^^^^^^^ Use of undeclared type or module `Duration`

error[E0425]: cannot find value `count` in this scope
  --> src/multi.rs:32:28
   |
10 | let mut p1 = mb.create_bar(count);
   |                            ^^^^^ not found in this scope

error[E0425]: cannot find value `count` in this scope
  --> src/multi.rs:34:17
   |
12 |     for _ in 0..count {
   |                 ^^^^^ not found in this scope

error[E0425]: cannot find value `count` in this scope
  --> src/multi.rs:44:28
   |
22 | let mut p2 = mb.create_bar(count * 2);
   |                            ^^^^^ not found in this scope

error[E0425]: cannot find value `count` in this scope
  --> src/multi.rs:46:17
   |
24 |     for _ in 0..count * 2 {
   |                 ^^^^^ not found in this scope

thread 'src/multi.rs - multi::MultiBar<Stdout>::new (line 25)' panicked at 'couldn't compile the test', librustdoc/test.rs:321:13


failures:
    src/multi.rs - multi::MultiBar<Stdout>::new (line 25)
    src/multi.rs - multi::MultiBar<T>::create_bar (line 130)
    src/multi.rs - multi::MultiBar<T>::listen (line 174)
    src/multi.rs - multi::MultiBar<T>::println (line 94)

test result: FAILED. 6 passed; 4 failed; 9 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--doc'
```


Discussion / hints:

Fix patch:
diff --git a/src/multi.rs b/src/multi.rs
index 86707ea7..8dc33e19 100644
--- a/src/multi.rs
+++ b/src/multi.rs
@@ -25,10 +25,12 @@ impl MultiBar<Stdout> {
     /// ```no_run
     /// use std::thread;
     /// use pbr::MultiBar;
+    /// use std::time::Duration;
     ///
     /// let mut mb = MultiBar::new();
     /// mb.println("Application header:");
     ///
+    /// # let count = 250;
     /// let mut p1 = mb.create_bar(count);
     /// let _ = thread::spawn(move || {
     ///     for _ in 0..count {
@@ -97,12 +99,13 @@ impl<T: Write> MultiBar<T> {
     /// let mut mb = MultiBar::new();
     /// mb.println("Application header:");
     ///
-    /// let mut p1 = MultiBar::create_bar(count);
+    /// # let count = 250;
+    /// let mut p1 = mb.create_bar(count);
     /// // ...
     ///
     /// mb.println("Text line between bar1 and bar2");
     ///
-    /// let mut p2 = MultiBar::create_bar(count);
+    /// let mut p2 = mb.create_bar(count);
     /// // ...
     ///
     /// mb.println("Text line between bar2 and bar3");
@@ -131,17 +134,18 @@ impl<T: Write> MultiBar<T> {
     /// use pbr::MultiBar;
     ///
     /// let mut mb = MultiBar::new();
+    /// # let (count1, count2, count3) = (250, 62500, 15625000);
     ///
     /// // progress bar in level 1
-    /// let mut p1 = MultiBar::create_bar(count1);
+    /// let mut p1 = mb.create_bar(count1);
     /// // ...
     ///
     /// // progress bar in level 2
-    /// let mut p2 = MultiBar::create_bar(count2);
+    /// let mut p2 = mb.create_bar(count2);
     /// // ...
     ///
     /// // progress bar in level 3
-    /// let mut p3 = MultiBar::create_bar(count3);
+    /// let mut p3 = mb.create_bar(count3);
     ///
     /// // ...
     /// mb.listen();
@@ -172,6 +176,7 @@ impl<T: Write> MultiBar<T> {
     /// # Examples
     ///
     /// ```no_run
+    /// use std::thread;
     /// use pbr::MultiBar;
     ///
     /// let mut mb = MultiBar::new();


Test patch: