libcore: rename vec::each(variable) to variable.each
This commit is contained in:
parent
3bbbb314ee
commit
9a292b3da5
@ -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]); }
|
||||
}
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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 */ }
|
||||
@ -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 */ }
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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]));
|
||||
@ -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);
|
||||
@ -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);
|
||||
|
@ -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
|
||||
@ -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 {
|
||||
@ -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).
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user