2012-11-01 17:14:36 -05:00
|
|
|
type boxedFn = { theFn: fn () -> uint };
|
|
|
|
|
|
|
|
fn createClosure (closedUint: uint) -> boxedFn {
|
2012-11-04 22:41:00 -06:00
|
|
|
{ theFn: fn@ () -> uint { closedUint } } //~ ERROR mismatched types
|
2012-11-01 17:14:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main () {
|
|
|
|
let aFn: boxedFn = createClosure(10);
|
|
|
|
|
|
|
|
let myInt: uint = aFn.theFn();
|
|
|
|
|
|
|
|
assert myInt == 10;
|
|
|
|
}
|