2012-11-01 15:14:36 -07:00
|
|
|
type boxedFn = { theFn: fn () -> uint };
|
|
|
|
|
|
|
|
fn createClosure (closedUint: uint) -> boxedFn {
|
2012-11-04 20:41:00 -08:00
|
|
|
{ theFn: fn@ () -> uint { closedUint } } //~ ERROR mismatched types
|
2012-11-01 15:14:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main () {
|
|
|
|
let aFn: boxedFn = createClosure(10);
|
|
|
|
|
2012-12-01 15:59:04 -08:00
|
|
|
let myInt: uint = (aFn.theFn)();
|
2012-11-01 15:14:36 -07:00
|
|
|
|
|
|
|
assert myInt == 10;
|
|
|
|
}
|