Skip to content

Commit dde4e58

Browse files
Eric Platonic
authored andcommitted
Made failing/working examples look alike.
The failing concurrency example was doing something different from the working example. This commit changes just enough of the failing example to (1) still fail with the same error, (2) tries to do the same as the working example (increment a vector value and print it). r? @steveklabnik
1 parent 1576142 commit dde4e58

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/doc/intro.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ fn main() {
428428
429429
let guards: Vec<_> = (0..3).map(|i| {
430430
Thread::scoped(move || {
431-
for j in 0..3 { numbers[j] += 1 }
431+
numbers[i] += 1;
432+
println!("numbers[{}] is {}", i, numbers[i]);
432433
});
433434
}).collect();
434435
}
@@ -437,10 +438,12 @@ fn main() {
437438
It gives us this error:
438439
439440
```text
440-
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
441-
7 Thread::scoped(move || {
442-
8 for j in 0..3 { numbers[j] += 1 }
443-
9 });
441+
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
442+
7 Thread::scoped(move || {
443+
8 numbers[i] += 1;
444+
9 println!("numbers[{}] is {}", i, numbers[i]);
445+
10 });
446+
error: aborting due to previous error
444447
```
445448
446449
It mentions that "captured outer variable in an `FnMut` closure".

0 commit comments

Comments
 (0)