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