2012-12-14 21:12:29 -06:00
|
|
|
trait Foo<T> {
|
|
|
|
fn f(&self, x: &T);
|
|
|
|
}
|
|
|
|
|
2013-01-30 21:42:06 -06:00
|
|
|
trait Bar : Foo<Self> {
|
2012-12-14 21:12:29 -06:00
|
|
|
fn g(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
x: int
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S : Foo<S> {
|
|
|
|
fn f(&self, x: &S) {
|
|
|
|
io::println(x.x.to_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S : Bar {
|
|
|
|
fn g(&self) {
|
|
|
|
self.f(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2012-12-14 21:12:29 -06:00
|
|
|
let s = S { x: 1 };
|
|
|
|
s.g();
|
|
|
|
}
|
|
|
|
|