mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Got test cases to pass, after some major surgery
This commit is contained in:
parent
9455eaf77b
commit
dd310d6c3b
@ -8,13 +8,16 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#[link (name = "issue2378a")];
|
||||||
|
#[crate_type = "lib"];
|
||||||
|
|
||||||
enum maybe<T> { just(T), nothing }
|
enum maybe<T> { just(T), nothing }
|
||||||
|
|
||||||
impl copy> for maybe<T> for methods<T {
|
impl <T:Copy> Index<uint,T> for maybe<T> {
|
||||||
fn ~[](idx: uint) -> T {
|
fn index(&self, idx: &uint) -> T {
|
||||||
match self {
|
match self {
|
||||||
just(t) { t }
|
&just(ref t) => copy *t,
|
||||||
nothing { fail!(); }
|
¬hing => { fail!(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,17 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use issue2378a;
|
#[link (name = "issue2378b")];
|
||||||
|
#[crate_type = "lib"];
|
||||||
|
|
||||||
|
extern mod issue2378a;
|
||||||
|
|
||||||
use issue2378a::maybe;
|
use issue2378a::maybe;
|
||||||
use issue2378a::methods;
|
|
||||||
|
|
||||||
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
|
struct two_maybes<T> {a: maybe<T>, b: maybe<T>}
|
||||||
|
|
||||||
impl copy> for two_maybes<T> for methods<T {
|
impl <T:Copy> Index<uint,(T,T)> for two_maybes<T> {
|
||||||
fn ~[](idx: uint) -> (T, T) {
|
fn index(&self, idx: &uint) -> (T, T) {
|
||||||
(self.a[idx], self.b[idx])
|
(self.a[*idx], self.b[*idx])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,17 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// xfail-test -- #2378 unfixed
|
|
||||||
// aux-build:issue2378a.rs
|
// aux-build:issue2378a.rs
|
||||||
// aux-build:issue2378b.rs
|
// aux-build:issue2378b.rs
|
||||||
|
// xfail-fast - check-fast doesn't understand aux-build
|
||||||
|
|
||||||
use issue2378a;
|
extern mod issue2378a;
|
||||||
use issue2378b;
|
extern mod issue2378b;
|
||||||
|
|
||||||
use issue2378a::{just, methods};
|
use issue2378a::{just};
|
||||||
use issue2378b::{methods};
|
use issue2378b::{two_maybes};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = {a: just(3), b: just(5)};
|
let x = two_maybes{a: just(3), b: just(5)};
|
||||||
assert!(x[0u] == (3, 5));
|
assert!(x[0u] == (3, 5));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user