This commit is contained in:
Niko Matsakis 2012-05-13 22:12:58 -07:00
parent 44c100c28d
commit 81caf926b4
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,10 @@
enum maybe<T> { just(T), nothing }
impl methods<T:copy> for maybe<T> {
fn [](idx: uint) -> T {
alt self {
just(t) { t }
nothing { fail; }
}
}
}

View File

@ -0,0 +1,12 @@
use issue2378a;
import issue2378a::maybe;
import issue2378a::methods;
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
impl methods<T:copy> for two_maybes<T> {
fn [](idx: uint) -> (T, T) {
(self.a[idx], self.b[idx])
}
}

View File

@ -0,0 +1,14 @@
// xfail-test -- #2378 unfixed
// aux-build:issue2378a.rs
// aux-build:issue2378b.rs
use issue2378a;
use issue2378b;
import issue2378a::{just, methods};
import issue2378b::{methods};
fn main() {
let x = {a: just(3), b: just(5)};
assert x[0u] == (3, 5);
}