mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-07 07:27:40 +00:00
18 lines
293 B
Rust
18 lines
293 B
Rust
![]() |
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;
|
||
|
}
|
||
|
|