]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
223e47cc LB |
11 | trait Foo<T> { |
12 | fn f(&self, x: &T); | |
13 | } | |
14 | ||
9cc50fc6 | 15 | trait Bar : Sized + Foo<Self> { |
223e47cc LB |
16 | fn g(&self); |
17 | } | |
18 | ||
19 | struct S { | |
c34b1796 | 20 | x: isize |
223e47cc LB |
21 | } |
22 | ||
23 | impl Foo<S> for S { | |
24 | fn f(&self, x: &S) { | |
1a4d82fc | 25 | println!("{}", x.x); |
223e47cc LB |
26 | } |
27 | } | |
28 | ||
29 | impl Bar for S { | |
30 | fn g(&self) { | |
31 | self.f(self); | |
32 | } | |
33 | } | |
34 | ||
35 | pub fn main() { | |
36 | let s = S { x: 1 }; | |
37 | s.g(); | |
38 | } |