]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/trait-inheritance2.rs
Implement trait inheritance for bounded type parameters
[rust.git] / src / test / run-pass / trait-inheritance2.rs
1 trait Foo { fn f() -> int; }
2 trait Bar { fn g() -> int; }
3 trait Baz { fn h() -> int; }
4
5 trait Quux: Foo, Bar, Baz { }
6
7 struct A { x: int }
8
9 impl A : Foo { fn f() -> int { 10 } }
10 impl A : Bar { fn g() -> int { 20 } }
11 impl A : Baz { fn h() -> int { 30 } }
12 impl A : Quux;
13
14 fn f<T: Quux Foo Bar Baz>(a: &T) {
15     assert a.f() == 10;
16     assert a.g() == 20;
17     assert a.h() == 30;
18 }
19
20 fn main() {
21     let a = &A { x: 3 };
22     f(a);
23 }
24