Skip to content

Commit

Permalink
libcore: rename vec::each(variable) to variable.each
Browse files Browse the repository at this point in the history
  • Loading branch information
recrack committed May 9, 2013
1 parent 3bbbb31 commit 9a292b3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/libcore/at_vec.rs
Expand Up @@ -102,7 +102,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
#[inline(always)]
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
do build_sized(lhs.len() + rhs.len()) |push| {
for vec::each(lhs) |x| { push(*x); }
for lhs.each |x| { push(*x); }
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
}
}
Expand All @@ -111,7 +111,7 @@ pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
/// Apply a function to each element of a vector and return the results
pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
do build_sized(v.len()) |push| {
for vec::each(v) |elem| {
for v.each |elem| {
push(f(elem));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/either.rs
Expand Up @@ -44,7 +44,7 @@ pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
//! Extracts from a vector of either all the left values

do vec::build_sized(eithers.len()) |push| {
for vec::each(eithers) |elt| {
for eithers.each |elt| {
match *elt {
Left(ref l) => { push(*l); }
_ => { /* fallthrough */ }
Expand All @@ -57,7 +57,7 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
//! Extracts from a vector of either all the right values

do vec::build_sized(eithers.len()) |push| {
for vec::each(eithers) |elt| {
for eithers.each |elt| {
match *elt {
Right(ref r) => { push(*r); }
_ => { /* fallthrough */ }
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/hash.rs
Expand Up @@ -378,7 +378,7 @@ impl Streaming for SipState {
fn result_str(&mut self) -> ~str {
let r = self.result_bytes();
let mut s = ~"";
for vec::each(r) |b| {
for r.each |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
s
Expand Down Expand Up @@ -478,7 +478,7 @@ mod tests {

fn to_hex_str(r: &[u8, ..8]) -> ~str {
let mut s = ~"";
for vec::each(*r) |b| {
for (*r).each |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
s
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/io.rs
Expand Up @@ -1200,7 +1200,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
fn wb() -> c_int { O_WRONLY as c_int }

let mut fflags: c_int = wb();
for vec::each(flags) |f| {
for flags.each |f| {
match *f {
Append => fflags |= O_APPEND as c_int,
Create => fflags |= O_CREAT as c_int,
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/os.rs
Expand Up @@ -1491,7 +1491,7 @@ mod tests {
fn test_env_getenv() {
let e = env();
assert!(vec::len(e) > 0u);
for vec::each(e) |p| {
for e.each |p| {
let (n, v) = copy *p;
debug!(copy n);
let v2 = getenv(n);
Expand Down Expand Up @@ -1583,7 +1583,7 @@ mod tests {
// Just assuming that we've got some contents in the current directory
assert!((vec::len(dirs) > 0u));

for vec::each(dirs) |dir| {
for dirs.each |dir| {
debug!(copy *dir);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/result.rs
Expand Up @@ -300,7 +300,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
ts: &[T], op: &fn(&T) -> Result<V,U>) -> Result<~[V],U> {

let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
for vec::each(ts) |t| {
for ts.each |t| {
match op(t) {
Ok(copy v) => vs.push(v),
Err(copy u) => return Err(u)
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/run.rs
Expand Up @@ -426,7 +426,7 @@ fn with_argv<T>(prog: &str, args: &[~str],
cb: &fn(**libc::c_char) -> T) -> T {
let mut argptrs = str::as_c_str(prog, |b| ~[b]);
let mut tmps = ~[];
for vec::each(args) |arg| {
for args.each |arg| {
let t = @copy *arg;
tmps.push(t);
argptrs.push_all(str::as_c_str(*t, |b| ~[b]));
Expand All @@ -445,7 +445,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
let mut tmps = ~[];
let mut ptrs = ~[];

for vec::each(*es) |e| {
for (*es).each |e| {
let (k,v) = copy *e;
let t = @(fmt!("%s=%s", k, v));
tmps.push(t);
Expand All @@ -470,7 +470,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
match *env {
Some(ref es) if !vec::is_empty(*es) => {
let mut blk : ~[u8] = ~[];
for vec::each(*es) |e| {
for (*es).each |e| {
let (k,v) = copy *e;
let t = fmt!("%s=%s", k, v);
let mut v : ~[u8] = ::cast::transmute(t);
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/str.rs
Expand Up @@ -189,7 +189,7 @@ pub fn from_char(ch: char) -> ~str {
pub fn from_chars(chs: &[char]) -> ~str {
let mut buf = ~"";
reserve(&mut buf, chs.len());
for vec::each(chs) |ch| {
for chs.each |ch| {
push_char(&mut buf, *ch);
}
buf
Expand Down Expand Up @@ -326,7 +326,7 @@ pub fn connect_slices(v: &[&str], sep: &str) -> ~str {
do as_buf(sep) |sepbuf, seplen| {
let seplen = seplen - 1;
let mut buf = ::cast::transmute_mut_unsafe(buf);
for vec::each(v) |ss| {
for v.each |ss| {
do as_buf(*ss) |ssbuf, sslen| {
let sslen = sslen - 1;
if first {
Expand Down Expand Up @@ -2407,7 +2407,7 @@ pub mod raw {
unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) {
let new_len = s.len() + bytes.len();
reserve_at_least(&mut *s, new_len);
for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); }
for bytes.each |byte| { push_byte(&mut *s, *byte); }
}

/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
Expand Down Expand Up @@ -3782,7 +3782,7 @@ mod tests {
0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
0x000a_u16 ]) ];

for vec::each(pairs) |p| {
for pairs.each |p| {
let (s, u) = copy *p;
assert!(to_utf16(s) == u);
assert!(from_utf16(u) == s);
Expand Down

0 comments on commit 9a292b3

Please sign in to comment.