about summary refs log tree commit diff
path: root/src/test/run-pass/trait-inheritance-multiple-params.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-11-28 12:34:30 -0800
committerBrian Anderson <banderson@mozilla.com>2012-11-29 18:10:11 -0800
commit78ee821154ba6034a86397d8540fec00c94e9282 (patch)
tree7e029752af04975fd78b6218c8a0d44010b51a42 /src/test/run-pass/trait-inheritance-multiple-params.rs
parentdaa89e086156099e3aa95577ec97f761e056e65e (diff)
downloadrust-78ee821154ba6034a86397d8540fec00c94e9282.tar.gz
rust-78ee821154ba6034a86397d8540fec00c94e9282.zip
Implement trait inheritance for bounded type parameters
Diffstat (limited to 'src/test/run-pass/trait-inheritance-multiple-params.rs')
-rw-r--r--src/test/run-pass/trait-inheritance-multiple-params.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/run-pass/trait-inheritance-multiple-params.rs b/src/test/run-pass/trait-inheritance-multiple-params.rs
new file mode 100644
index 00000000000..0a5330b68f8
--- /dev/null
+++ b/src/test/run-pass/trait-inheritance-multiple-params.rs
@@ -0,0 +1,23 @@
+trait A { fn a(&self) -> int; }
+trait B: A { fn b(&self) -> int; }
+trait C: A { fn c(&self) -> int; }
+
+struct S { bogus: () }
+
+impl S: A { fn a(&self) -> int { 10 } }
+impl S: B { fn b(&self) -> int { 20 } }
+impl S: C { fn c(&self) -> int { 30 } }
+
+// Multiple type params, multiple levels of inheritance
+fn f<X: A, Y: B, Z: C>(x: &X, y: &Y, z: &Z) {
+    assert x.a() == 10;
+    assert y.a() == 10;
+    assert y.b() == 20;
+    assert z.a() == 10;
+    assert z.c() == 30;
+}
+
+fn main() {
+    let s = &S { bogus: () };
+    f(s, s, s);
+}
\ No newline at end of file