diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-11-28 12:34:30 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-11-29 18:10:11 -0800 |
| commit | 78ee821154ba6034a86397d8540fec00c94e9282 (patch) | |
| tree | 7e029752af04975fd78b6218c8a0d44010b51a42 /src/test/run-pass/trait-inheritance-overloading-simple.rs | |
| parent | daa89e086156099e3aa95577ec97f761e056e65e (diff) | |
| download | rust-78ee821154ba6034a86397d8540fec00c94e9282.tar.gz rust-78ee821154ba6034a86397d8540fec00c94e9282.zip | |
Implement trait inheritance for bounded type parameters
Diffstat (limited to 'src/test/run-pass/trait-inheritance-overloading-simple.rs')
| -rw-r--r-- | src/test/run-pass/trait-inheritance-overloading-simple.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs new file mode 100644 index 00000000000..13867eed52f --- /dev/null +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -0,0 +1,25 @@ +use cmp::Eq; + +trait MyNum : Eq { } + +struct MyInt { val: int } + +impl MyInt : Eq { + pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val } + pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } +} + +impl MyInt : MyNum; + +fn f<T:MyNum>(x: T, y: T) -> bool { + return x == y; +} + +pure fn mi(v: int) -> MyInt { MyInt { val: v } } + +fn main() { + let (x, y, z) = (mi(3), mi(5), mi(3)); + assert x != y; + assert x == z; +} + |
