PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/newtype.rs

http://github.com/jruderman/rust
Rust | 8 lines | 6 code | 2 blank | 0 comment | 1 complexity | 5e62e3808d5cae173ca68ddad156803f MD5 | raw file
1enum mytype = {compute: extern fn(mytype) -> int, val: int};
2
3fn compute(i: mytype) -> int { return i.val + 20; }
4
5fn main() {
6    let myval = mytype({compute: compute, val: 30});
7    assert (myval.compute(myval) == 50);
8}