about summary refs log tree commit diff
path: root/src/test/run-pass/trait-inheritance-self.rs
blob: 5eb87b7a96b8be9ce74e545ea4b777ede0507ea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
trait Foo<T> {
    fn f(&self, x: &T);
}

trait Bar : Foo<Self> {
    fn g(&self);
}

struct S {
    x: int
}

impl Foo<S> for S {
    fn f(&self, x: &S) {
        io::println(x.x.to_str());
    }
}

impl Bar for S {
    fn g(&self) {
        self.f(self);
    }
}

pub fn main() {
    let s = S { x: 1 };
    s.g();
}