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
|
|
|
|
}
|
|
|
|
|
2013-02-14 13:47:00 -06:00
|
|
|
impl Foo<S> for S {
|
2012-12-14 21:12:29 -06:00
|
|
|
fn f(&self, x: &S) {
|
2013-05-24 21:35:29 -05:00
|
|
|
println(x.x.to_str());
|
2012-12-14 21:12:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 13:47:00 -06:00
|
|
|
impl Bar for S {
|
2012-12-14 21:12:29 -06:00
|
|
|
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();
|
|
|
|
}
|