rust/src/test/run-pass/sendfn-spawn-with-fn-arg.rs

21 lines
380 B
Rust
Raw Normal View History

2011-12-15 18:10:01 -06:00
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_full(core::error, *three + n); // will copy x into the closure
2011-12-15 18:10:01 -06:00
assert(*three == 3);
};
task::spawn(fn_to_send, test05_start);
}