rust/src/test/compile-fail/issue-1896-1.rs

13 lines
285 B
Rust
Raw Normal View History

2012-11-01 15:14:36 -07:00
type boxedFn = { theFn: fn () -> uint };
fn createClosure (closedUint: uint) -> boxedFn {
{ 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;
}