Implement trait inheritance for bounded type parameters
This commit is contained in:
parent
daa89e0861
commit
78ee821154
38 changed files with 1004 additions and 176 deletions
17
src/test/run-pass/trait-inheritance-cross-trait-call.rs
Normal file
17
src/test/run-pass/trait-inheritance-cross-trait-call.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
trait Foo { fn f() -> int; }
|
||||
trait Bar : Foo { fn g() -> int; }
|
||||
|
||||
struct A { x: int }
|
||||
|
||||
impl A : Foo { fn f() -> int { 10 } }
|
||||
|
||||
impl A : Bar {
|
||||
// Testing that this impl can call the impl of Foo
|
||||
fn g() -> int { self.f() }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = &A { x: 3 };
|
||||
assert a.g() == 10;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue