13 lines
256 B
Rust
13 lines
256 B
Rust
|
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;
|
||
|
}
|