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
This commit is contained in:
Eric Platon 2015-03-02 15:15:24 +09:00 committed by Eric Platon
parent 1576142495
commit dde4e5885e

View File

@ -428,7 +428,8 @@ fn main() {
let guards: Vec<_> = (0..3).map(|i| { let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || { Thread::scoped(move || {
for j in 0..3 { numbers[j] += 1 } numbers[i] += 1;
println!("numbers[{}] is {}", i, numbers[i]);
}); });
}).collect(); }).collect();
} }
@ -437,10 +438,12 @@ fn main() {
It gives us this error: It gives us this error:
```text ```text
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure 7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || { 7 Thread::scoped(move || {
8 for j in 0..3 { numbers[j] += 1 } 8 numbers[i] += 1;
9 }); 9 println!("numbers[{}] is {}", i, numbers[i]);
10 });
error: aborting due to previous error
``` ```
It mentions that "captured outer variable in an `FnMut` closure". It mentions that "captured outer variable in an `FnMut` closure".