test: Add a test for trait inheritance with self as a type parameter. rs=test-only
This commit is contained in:
parent
53b181dd47
commit
593f414254
|
@ -0,0 +1,29 @@
|
|||
trait Foo<T> {
|
||||
fn f(&self, x: &T);
|
||||
}
|
||||
|
||||
trait Bar : Foo<self> {
|
||||
fn g(&self);
|
||||
}
|
||||
|
||||
struct S {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl S : Foo<S> {
|
||||
fn f(&self, x: &S) {
|
||||
io::println(x.x.to_str());
|
||||
}
|
||||
}
|
||||
|
||||
impl S : Bar {
|
||||
fn g(&self) {
|
||||
self.f(self);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S { x: 1 };
|
||||
s.g();
|
||||
}
|
||||
|
Loading…
Reference in New Issue