blob: 37c2ff63c6ab1dc2dc313d079dcff7b00d958520 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// run-pass
#![allow(dead_code)]
trait Foo { fn f(&self) -> isize; }
trait Bar : Foo { fn g(&self) -> isize; }
struct A { x: isize }
impl Foo for A { fn f(&self) -> isize { 10 } }
impl Bar for A { fn g(&self) -> isize { 20 } }
// Call a function on Foo, given a T: Bar
fn gg<T:Bar>(a: &T) -> isize {
a.f()
}
pub fn main() {
let a = &A { x: 3 };
assert_eq!(gg(a), 10);
}
|