rust/src/test/run-pass/block-arg-call-as.rs

27 lines
404 B
Rust
Raw Normal View History

use std;
fn asSendfn( f : fn~()->uint ) -> uint {
2012-08-01 19:30:05 -05:00
return f();
}
fn asLambda( f : fn@()->uint ) -> uint {
2012-08-01 19:30:05 -05:00
return f();
}
2012-01-23 16:59:00 -06:00
fn asBlock( f : fn&()->uint ) -> uint {
2012-08-01 19:30:05 -05:00
return f();
2012-01-23 16:59:00 -06:00
}
fn asAny( f : fn()->uint ) -> uint {
2012-08-01 19:30:05 -05:00
return f();
}
fn main() {
2012-06-30 18:19:07 -05:00
let x = asSendfn(|| 22u);
assert(x == 22u);
2012-06-30 18:19:07 -05:00
let x = asLambda(|| 22u);
assert(x == 22u);
2012-06-30 18:19:07 -05:00
let x = asBlock(|| 22u);
assert(x == 22u);
}