30 lines
312 B
Rust
30 lines
312 B
Rust
trait Foo<T> {
|
|
fn f(&self, x: &T);
|
|
}
|
|
|
|
trait Bar : Foo<Self> {
|
|
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);
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let s = S { x: 1 };
|
|
s.g();
|
|
}
|
|
|