2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2012-09-13 13:11:08 -07:00
|
|
|
trait Foo {
|
|
|
|
fn f(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
2015-03-25 17:06:52 -07:00
|
|
|
x: isize
|
2012-09-13 13:11:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
trait Baz {
|
|
|
|
fn g(&self);
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl<T:Baz> Foo for T {
|
2012-09-13 13:11:08 -07:00
|
|
|
fn f(&self) {
|
|
|
|
self.g();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Baz for Bar {
|
2012-09-13 13:11:08 -07:00
|
|
|
fn g(&self) {
|
2014-01-09 21:06:55 +11:00
|
|
|
println!("{}", self.x);
|
2012-09-13 13:11:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-09-13 13:11:08 -07:00
|
|
|
let y = Bar { x: 42 };
|
|
|
|
y.f();
|
2012-12-13 13:05:22 -08:00
|
|
|
}
|