/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
- enum mytype = {compute: extern fn(mytype) -> int, val: int};
- fn compute(i: mytype) -> int { return i.val + 20; }
- fn main() {
- let myval = mytype({compute: compute, val: 30});
- assert (myval.compute(myval) == 50);
- }