2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
trait Foo { fn f(&self) -> isize; }
|
|
|
|
trait Bar : Foo { fn g(&self) -> isize; }
|
2012-10-05 13:50:53 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
struct A { x: isize }
|
2012-10-05 13:50:53 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
impl Foo for A { fn f(&self) -> isize { 10 } }
|
|
|
|
impl Bar for A { fn g(&self) -> isize { 20 } }
|
2012-10-05 13:50:53 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn ff<T:Foo>(a: &T) -> isize {
|
2012-11-28 14:34:30 -06:00
|
|
|
a.f()
|
2012-10-05 13:50:53 -05:00
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn gg<T:Bar>(a: &T) -> isize {
|
2012-11-28 14:34:30 -06:00
|
|
|
a.g()
|
2012-10-05 13:50:53 -05:00
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2012-11-28 14:34:30 -06:00
|
|
|
let a = &A { x: 3 };
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(ff(a), 10);
|
|
|
|
assert_eq!(gg(a), 20);
|
2012-10-05 13:50:53 -05:00
|
|
|
}
|