diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 2eddc301a83..4ed0de2a138 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -72,7 +72,7 @@ struct CreatureInfo { fn show_color_list(set: Vec) -> String { let mut out = String::new(); for col in set.iter() { - out.push_char(' '); + out.push(' '); out.push_str(col.to_string().as_slice()); } out diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 77311edba4e..e61ed474504 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -85,8 +85,9 @@ impl<'a> Iterator for AAGen<'a> { fn make_fasta>( wr: &mut W, header: &str, mut it: I, mut n: uint) + -> std::io::IoResult<()> { - wr.write(header.as_bytes()); + try!(wr.write(header.as_bytes())); let mut line = [0u8, .. LINE_LENGTH + 1]; while n > 0 { let nb = min(LINE_LENGTH, n); @@ -95,11 +96,12 @@ fn make_fasta>( } n -= nb; line[nb] = '\n' as u8; - wr.write(line[..nb+1]); + try!(wr.write(line[..nb+1])); } + Ok(()) } -fn run(writer: &mut W) { +fn run(writer: &mut W) -> std::io::IoResult<()> { let args = os::args(); let args = args.as_slice(); let n = if os::getenv("RUST_BENCH").is_some() { @@ -129,21 +131,22 @@ fn run(writer: &mut W) { ('g', 0.1975473066391), ('t', 0.3015094502008)]; - make_fasta(writer, ">ONE Homo sapiens alu\n", - alu.as_bytes().iter().cycle().map(|c| *c), n * 2); - make_fasta(writer, ">TWO IUB ambiguity codes\n", - AAGen::new(rng, iub), n * 3); - make_fasta(writer, ">THREE Homo sapiens frequency\n", - AAGen::new(rng, homosapiens), n * 5); + try!(make_fasta(writer, ">ONE Homo sapiens alu\n", + alu.as_bytes().iter().cycle().map(|c| *c), n * 2)); + try!(make_fasta(writer, ">TWO IUB ambiguity codes\n", + AAGen::new(rng, iub), n * 3)); + try!(make_fasta(writer, ">THREE Homo sapiens frequency\n", + AAGen::new(rng, homosapiens), n * 5)); - writer.flush(); + writer.flush() } fn main() { - if os::getenv("RUST_BENCH").is_some() { + let res = if os::getenv("RUST_BENCH").is_some() { let mut file = BufferedWriter::new(File::create(&Path::new("./shootout-fasta.data"))); - run(&mut file); + run(&mut file) } else { - run(&mut io::stdout()); - } + run(&mut io::stdout()) + }; + res.unwrap() } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 8c08fc4caa1..1799504eb47 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -123,8 +123,8 @@ struct Entry { } struct Table { - count: uint, - items: Vec>> } + items: Vec>> +} struct Items<'a> { cur: Option<&'a Entry>, @@ -134,7 +134,6 @@ struct Items<'a> { impl Table { fn new() -> Table { Table { - count: 0, items: Vec::from_fn(TABLE_SIZE, |_| None), } } @@ -165,7 +164,7 @@ impl Table { let index = key.hash() % (TABLE_SIZE as u64); { - if self.items.get(index as uint).is_none() { + if self.items[index as uint].is_none() { let mut entry = box Entry { code: key, count: 0, @@ -178,7 +177,7 @@ impl Table { } { - let entry = &mut *self.items.get_mut(index as uint).get_mut_ref(); + let entry = self.items.get_mut(index as uint).as_mut().unwrap(); if entry.code == key { c.f(&mut **entry); return; @@ -286,7 +285,7 @@ fn get_sequence(r: &mut R, key: &str) -> Vec { res.push_all(l.as_slice().trim().as_bytes()); } for b in res.iter_mut() { - *b = b.to_ascii().to_upper().to_byte(); + *b = b.to_ascii().to_uppercase().to_byte(); } res } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 66fe52d9ec7..a9d0f4a82b4 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -109,8 +109,8 @@ fn mandelbrot(w: uint, mut out: W) -> io::IoResult<()> { for res in precalc_futures.into_iter() { let (rs, is) = res.unwrap(); - precalc_r.push_all_move(rs); - precalc_i.push_all_move(is); + precalc_r.extend(rs.into_iter()); + precalc_i.extend(is.into_iter()); } assert_eq!(precalc_r.len(), w); diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 10408dd0ef4..8e837864185 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -193,9 +193,9 @@ fn is_board_unfeasible(board: u64, masks: &Vec>>) -> bool { // Filter the masks that we can prove to result to unfeasible board. fn filter_masks(masks: &mut Vec>>) { for i in range(0, masks.len()) { - for j in range(0, masks.get(i).len()) { + for j in range(0, (*masks)[i].len()) { *masks.get_mut(i).get_mut(j) = - masks.get(i).get(j).iter().map(|&m| m) + (*masks)[i][j].iter().map(|&m| m) .filter(|&m| !is_board_unfeasible(m, masks)) .collect(); } @@ -287,12 +287,12 @@ fn search( while board & (1 << i) != 0 && i < 50 {i += 1;} // the board is full: a solution is found. if i >= 50 {return handle_sol(&cur, data);} - let masks_at = masks.get(i); + let masks_at = &masks[i]; // for every unused piece for id in range(0u, 10).filter(|id| board & (1 << (id + 50)) == 0) { // for each mask that fits on the board - for m in masks_at.get(id).iter().filter(|&m| board & *m == 0) { + for m in masks_at[id].iter().filter(|&m| board & *m == 0) { // This check is too costly. //if is_board_unfeasible(board | m, masks) {continue;} search(masks, board | *m, i + 1, Cons(*m, &cur), data); @@ -306,7 +306,7 @@ fn par_search(masks: Vec>>) -> Data { // launching the search in parallel on every masks at minimum // coordinate (0,0) - for m in masks.get(0).iter().flat_map(|masks_pos| masks_pos.iter()) { + for m in (*masks)[0].iter().flat_map(|masks_pos| masks_pos.iter()) { let masks = masks.clone(); let tx = tx.clone(); let m = *m; diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index a945e0f7796..3c8e8389564 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -133,14 +133,14 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) { fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 { let mut e = 0.0; - let mut bodies = bodies.as_slice(); + let mut bodies = bodies.iter(); loop { - let bi = match bodies.shift_ref() { + let bi = match bodies.next() { Some(bi) => bi, None => break }; e += (bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz) * bi.mass / 2.0; - for bj in bodies.iter() { + for bj in bodies.clone() { let dx = bi.x - bj.x; let dy = bi.y - bj.y; let dz = bi.z - bj.z;