2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2012-12-14 21:12:29 -06:00
|
|
|
trait Foo<T> {
|
|
|
|
fn f(&self, x: &T);
|
|
|
|
}
|
|
|
|
|
2015-12-15 03:31:58 -06:00
|
|
|
trait Bar : Sized + Foo<Self> {
|
2012-12-14 21:12:29 -06:00
|
|
|
fn g(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2015-03-25 19:06:52 -05:00
|
|
|
x: isize
|
2012-12-14 21:12:29 -06:00
|
|
|
}
|
|
|
|
|
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) {
|
2014-01-09 04:06:55 -06:00
|
|
|
println!("{}", x.x);
|
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();
|
|
|
|
}
|