summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/region-pointer-simple.rs
blob: 0456ca931156ec5b833c02a69a06c0d63c92504f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass
trait Foo {
    fn f(&self) -> isize;
}

struct A {
    x: isize
}

impl Foo for A {
    fn f(&self) -> isize {
        println!("Today's number is {}", self.x);
        return self.x;
    }
}

pub fn main() {
    let a = A { x: 3 };
    let b = (&a) as &dyn Foo;
    assert_eq!(b.f(), 3);
}