rust/src/test/run-pass/issue-1896-1.rs

13 lines
256 B
Rust
Raw Normal View History

2012-11-01 17:14:36 -05:00
type boxedFn = { theFn: fn () -> uint };
fn createClosure (closedUint: uint) -> boxedFn {
{ theFn: fn@ () -> uint { closedUint } }
}
fn main () {
let aFn: boxedFn = createClosure(10);
let myInt: uint = aFn.theFn();
assert myInt == 10;
}