@@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan};
161
161
162
162
let (port, chan): (Port<int>, Chan<int>) = stream();
163
163
164
- do spawn |move chan | {
164
+ do spawn || {
165
165
let result = some_expensive_computation();
166
166
chan.send(result);
167
167
}
@@ -192,7 +192,7 @@ spawns the child task.
192
192
# use pipes::{stream, Port, Chan};
193
193
# fn some_expensive_computation() -> int { 42 }
194
194
# let (port, chan) = stream();
195
- do spawn |move chan | {
195
+ do spawn || {
196
196
let result = some_expensive_computation();
197
197
chan.send(result);
198
198
}
@@ -229,7 +229,7 @@ following program is ill-typed:
229
229
# fn some_expensive_computation() -> int { 42 }
230
230
let (port, chan) = stream();
231
231
232
- do spawn |move chan| {
232
+ do spawn {
233
233
chan.send(some_expensive_computation());
234
234
}
235
235
@@ -248,12 +248,12 @@ Instead we can use a `SharedChan`, a type that allows a single
248
248
use pipes::{stream, SharedChan};
249
249
250
250
let (port, chan) = stream();
251
- let chan = SharedChan(move chan);
251
+ let chan = SharedChan(chan);
252
252
253
253
for uint::range(0, 3) |init_val| {
254
254
// Create a new channel handle to distribute to the child task
255
255
let child_chan = chan.clone();
256
- do spawn |move child_chan| {
256
+ do spawn {
257
257
child_chan.send(some_expensive_computation(init_val));
258
258
}
259
259
}
@@ -283,10 +283,10 @@ might look like the example below.
283
283
// Create a vector of ports, one for each child task
284
284
let ports = do vec::from_fn(3) |init_val| {
285
285
let (port, chan) = stream();
286
- do spawn |move chan| {
286
+ do spawn {
287
287
chan.send(some_expensive_computation(init_val));
288
288
}
289
- move port
289
+ port
290
290
};
291
291
292
292
// Wait on each port, accumulating the results
@@ -398,13 +398,13 @@ before returning. Hence:
398
398
# fn sleep_forever() { loop { task::yield() } }
399
399
# do task::try {
400
400
let (receiver, sender): (Port<int>, Chan<int>) = stream();
401
- do spawn |move receiver| { // Bidirectionally linked
401
+ do spawn { // Bidirectionally linked
402
402
// Wait for the supervised child task to exist.
403
403
let message = receiver.recv();
404
404
// Kill both it and the parent task.
405
405
assert message != 42;
406
406
}
407
- do try |move sender| { // Unidirectionally linked
407
+ do try { // Unidirectionally linked
408
408
sender.send(42);
409
409
sleep_forever(); // Will get woken up by force
410
410
}
@@ -505,7 +505,7 @@ Here is the code for the parent task:
505
505
506
506
let (from_child, to_child) = DuplexStream();
507
507
508
- do spawn |move to_child| {
508
+ do spawn {
509
509
stringifier(&to_child);
510
510
};
511
511
0 commit comments