summary refs log tree commit diff
path: root/src/test/run-pass/trait-region-pointer-simple.rs
blob: dfcbfc3993f16dbcf8216df174c72f77410994c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}