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

13 lines
283 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 } } //~ 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;
}