1
Fork 0

Implement trait inheritance for bounded type parameters

This commit is contained in:
Brian Anderson 2012-11-28 12:34:30 -08:00
parent daa89e0861
commit 78ee821154
38 changed files with 1004 additions and 176 deletions

View 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;
}