File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -428,7 +428,8 @@ fn main() {
428
428
429
429
let guards: Vec< _> = (0..3).map(| i| {
430
430
Thread::scoped(move || {
431
- for j in 0..3 { numbers[j] += 1 }
431
+ numbers[i] += 1;
432
+ println! (" numbers[{}] is {}" , i, numbers[i]);
432
433
});
433
434
}).collect();
434
435
}
@@ -437,10 +438,12 @@ fn main() {
437
438
It gives us this error:
438
439
439
440
` ` ` 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
444
447
` ` `
445
448
446
449
It mentions that " captured outer variable in an ` FnMut` closure" .
You can’t perform that action at this time.
0 commit comments