rust/src/test/run-pass/trait-region-pointer-simple.rs
2012-10-05 16:57:13 -07:00

22 lines
276 B
Rust

trait Foo {
fn f() -> int;
}
struct A {
x: int
}
impl A : Foo {
fn f() -> int {
io::println(~"Today's number is " + self.x.to_str());
return self.x;
}
}
fn main() {
let a = A { x: 3 };
let b = (&a) as &Foo;
assert b.f() == 3;
}