Skip to content

Commit

Permalink
libstd: rename vec::each(var) to var.each
Browse files Browse the repository at this point in the history
  • Loading branch information
recrack committed May 9, 2013
1 parent 472d9f3 commit d4fa0f1
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/libcore/hash.rs
Expand Up @@ -24,7 +24,6 @@ use cast;
use rt::io::Writer;
use to_bytes::IterBytes;
use uint;
use vec;

// Alias `SipState` to `State`.
pub use State = hash::SipState;
Expand Down
7 changes: 3 additions & 4 deletions src/libstd/arc.rs
Expand Up @@ -484,7 +484,6 @@ mod tests {

use core::cell::Cell;
use core::task;
use core::vec;

#[test]
fn manually_share_arc() {
Expand Down Expand Up @@ -683,7 +682,7 @@ mod tests {
}

// Wait for children to pass their asserts
for vec::each(children) |r| {
for children.each |r| {
r.recv();
}

Expand Down Expand Up @@ -748,7 +747,7 @@ mod tests {
assert!(*state == 42);
*state = 31337;
// send to other readers
for vec::each(reader_convos) |x| {
for reader_convos.each |x| {
match *x {
(ref rc, _) => rc.send(()),
}
Expand All @@ -757,7 +756,7 @@ mod tests {
let read_mode = arc.downgrade(write_mode);
do (&read_mode).read |state| {
// complete handshake with other readers
for vec::each(reader_convos) |x| {
for reader_convos.each |x| {
match *x {
(_, ref rp) => rp.recv(),
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/getopts.rs
Expand Up @@ -368,7 +368,7 @@ pub fn opt_count(mm: &Matches, nm: &str) -> uint {

/// Returns true if any of several options were matched
pub fn opts_present(mm: &Matches, names: &[~str]) -> bool {
for vec::each(names) |nm| {
for names.each |nm| {
match find_opt(mm.opts, mkname(*nm)) {
Some(id) if !mm.vals[id].is_empty() => return true,
_ => (),
Expand All @@ -395,7 +395,7 @@ pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
* option took an argument
*/
pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str {
for vec::each(names) |nm| {
for names.each |nm| {
match opt_val(mm, *nm) {
Val(copy s) => return s,
_ => ()
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net_ip.rs
Expand Up @@ -425,7 +425,7 @@ mod test {
let results = result::unwrap(ga_result);
debug!("test_get_addr: Number of results for %s: %?",
localhost_name, vec::len(results));
for vec::each(results) |r| {
for results.each |r| {
let ipv_prefix = match *r {
Ipv4(_) => ~"IPv4",
Ipv6(_) => ~"IPv6"
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sha1.rs
Expand Up @@ -250,7 +250,7 @@ pub fn sha1() -> @Sha1 {
fn result_str(&mut self) -> ~str {
let rr = mk_result(self);
let mut s = ~"";
for vec::each(rr) |b| {
for rr.each |b| {
let hex = uint::to_str_radix(*b as uint, 16u);
if hex.len() == 1 {
s += "0";
Expand Down Expand Up @@ -378,7 +378,7 @@ mod tests {
// Test that it works when accepting the message all at once

let mut sh = sha1::sha1();
for vec::each(tests) |t| {
for tests.each |t| {
sh.input_str(t.input);
let out = sh.result();
check_vec_eq(t.output, out);
Expand All @@ -392,7 +392,7 @@ mod tests {


// Test that it works when accepting the message in pieces
for vec::each(tests) |t| {
for tests.each |t| {
let len = str::len(t.input);
let mut left = len;
while left > 0u {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sort.rs
Expand Up @@ -859,7 +859,7 @@ mod test_qsort {
let immut_names = names;

let pairs = vec::zip_slice(expected, immut_names);
for vec::each(pairs) |p| {
for pairs.each |p| {
let (a, b) = *p;
debug!("%d %d", a, b);
assert!((a == b));
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sort_stage0.rs
Expand Up @@ -852,7 +852,7 @@ mod test_qsort {
let immut_names = names;

let pairs = vec::zip_slice(expected, immut_names);
for vec::each(pairs) |p| {
for pairs.each |p| {
let (a, b) = *p;
debug!("%d %d", a, b);
assert!((a == b));
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sync.rs
Expand Up @@ -997,7 +997,7 @@ mod tests {
}
}
}
for vec::each(sibling_convos) |p| {
for sibling_convos.each |p| {
let _ = p.recv(); // wait for sibling to get in the mutex
}
do m2.lock { }
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/term.rs
Expand Up @@ -13,7 +13,6 @@
use core::io;
use core::option;
use core::os;
use core::vec;

// FIXME (#2807): Windows support.

Expand Down Expand Up @@ -50,7 +49,7 @@ pub fn color_supported() -> bool {
~"screen-bce", ~"xterm-256color"];
return match os::getenv(~"TERM") {
option::Some(ref env) => {
for vec::each(supported_terms) |term| {
for supported_terms.each |term| {
if *term == *env { return true; }
}
false
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/test.rs
Expand Up @@ -355,7 +355,7 @@ fn print_failures(st: &ConsoleTestState) {
failures.push(name.to_str());
}
sort::tim_sort(failures);
for vec::each(failures) |name| {
for failures.each |name| {
st.out.write_line(fmt!(" %s", name.to_str()));
}
}
Expand Down Expand Up @@ -928,7 +928,7 @@ mod tests {
{
fn testfn() { }
let mut tests = ~[];
for vec::each(names) |name| {
for names.each |name| {
let test = TestDescAndFn {
desc: TestDesc {
name: DynTestName(*name),
Expand All @@ -954,7 +954,7 @@ mod tests {

let pairs = vec::zip(expected, filtered);

for vec::each(pairs) |p| {
for pairs.each |p| {
match *p {
(ref a, ref b) => {
assert!((*a == b.desc.name.to_str()));
Expand Down
17 changes: 8 additions & 9 deletions src/libstd/time.rs
Expand Up @@ -861,7 +861,6 @@ mod tests {
use core::result;
use core::result::{Err, Ok};
use core::str;
use core::vec;

fn test_get_time() {
static some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z
Expand Down Expand Up @@ -1028,31 +1027,31 @@ mod tests {
}
}

for vec::each([
for [
~"Sunday",
~"Monday",
~"Tuesday",
~"Wednesday",
~"Thursday",
~"Friday",
~"Saturday"
]) |day| {
].each |day| {
assert!(test(*day, ~"%A"));
}

for vec::each([
for [
~"Sun",
~"Mon",
~"Tue",
~"Wed",
~"Thu",
~"Fri",
~"Sat"
]) |day| {
].each |day| {
assert!(test(*day, ~"%a"));
}

for vec::each([
for [
~"January",
~"February",
~"March",
Expand All @@ -1065,11 +1064,11 @@ mod tests {
~"October",
~"November",
~"December"
]) |day| {
].each |day| {
assert!(test(*day, ~"%B"));
}

for vec::each([
for [
~"Jan",
~"Feb",
~"Mar",
Expand All @@ -1082,7 +1081,7 @@ mod tests {
~"Oct",
~"Nov",
~"Dec"
]) |day| {
].each |day| {
assert!(test(*day, ~"%b"));
}

Expand Down

0 comments on commit d4fa0f1

Please sign in to comment.