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

@ -2,18 +2,19 @@
// aux-build:trait_inheritance_overloading_xc.rs
extern mod trait_inheritance_overloading_xc;
use trait_inheritance_overloading_xc::MyNum;
use trait_inheritance_overloading_xc::{MyNum, MyInt};
fn f<T:Copy MyNum>(x: T, y: T) -> (T, T, T) {
return (x + y, x - y, x * y);
}
pure fn mi(v: int) -> MyInt { MyInt { val: v } }
fn main() {
let (x, y) = (3, 5);
let (x, y) = (mi(3), mi(5));
let (a, b, c) = f(x, y);
assert a == 8;
assert b == -2;
assert c == 15;
assert a == mi(8);
assert b == mi(-2);
assert c == mi(15);
}