first test of sendable fns (passes)
This commit is contained in:
parent
21cc0c6e69
commit
4465c1ad02
20
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
Normal file
20
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use std;
|
||||||
|
|
||||||
|
import std::comm;
|
||||||
|
import std::comm::chan;
|
||||||
|
import std::comm::send;
|
||||||
|
|
||||||
|
fn main() { test05(); }
|
||||||
|
|
||||||
|
fn test05_start(&&f: sendfn(int)) {
|
||||||
|
f(22);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test05() {
|
||||||
|
let three = ~3;
|
||||||
|
let fn_to_send = sendfn(n: int) {
|
||||||
|
log_err *three + n; // will copy x into the closure
|
||||||
|
assert(*three == 3);
|
||||||
|
};
|
||||||
|
task::spawn(fn_to_send, test05_start);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user