blob: 7e478757404837e00ccb10124ed7b86863457d78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
fn use(_i: int) {}
fn foo() {
// Here, i is *moved* into the closure: Not actually OK
let mut i = 0;
do task::spawn {
use(i); //~ ERROR mutable variables cannot be implicitly captured
}
}
fn bar() {
// Here, i would be implicitly *copied* but it
// is mutable: bad
let mut i = 0;
while i < 10 {
do task::spawn {
use(i); //~ ERROR mutable variables cannot be implicitly captured
}
i += 1;
}
}
fn car() {
// Here, i is mutable, but *explicitly* copied:
let mut i = 0;
while i < 10 {
do task::spawn |copy i| {
use(i);
}
i += 1;
}
}
fn main() {
}
|