Skip to content

Commit 936c07d

Browse files
committed
auto merge of #6328 : recrack/rust/rename_cleanup, r=sanxiyn
rename vec::each(var) to var.each > librustc, libsyntax, libstd, librustdoc, libcore
2 parents 101d4bf + c02064d commit 936c07d

39 files changed

+94
-100
lines changed

src/libcore/at_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
102102
#[inline(always)]
103103
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
104104
do build_sized(lhs.len() + rhs.len()) |push| {
105-
for vec::each(lhs) |x| { push(*x); }
105+
for lhs.each |x| { push(*x); }
106106
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
107107
}
108108
}
@@ -111,7 +111,7 @@ pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
111111
/// Apply a function to each element of a vector and return the results
112112
pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
113113
do build_sized(v.len()) |push| {
114-
for vec::each(v) |elem| {
114+
for v.each |elem| {
115115
push(f(elem));
116116
}
117117
}

src/libcore/either.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
4444
//! Extracts from a vector of either all the left values
4545
4646
do vec::build_sized(eithers.len()) |push| {
47-
for vec::each(eithers) |elt| {
47+
for eithers.each |elt| {
4848
match *elt {
4949
Left(ref l) => { push(*l); }
5050
_ => { /* fallthrough */ }
@@ -57,7 +57,7 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
5757
//! Extracts from a vector of either all the right values
5858
5959
do vec::build_sized(eithers.len()) |push| {
60-
for vec::each(eithers) |elt| {
60+
for eithers.each |elt| {
6161
match *elt {
6262
Right(ref r) => { push(*r); }
6363
_ => { /* fallthrough */ }

src/libcore/hash.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use cast;
2424
use rt::io::Writer;
2525
use to_bytes::IterBytes;
2626
use uint;
27-
use vec;
2827

2928
// Alias `SipState` to `State`.
3029
pub use State = hash::SipState;
@@ -378,7 +377,7 @@ impl Streaming for SipState {
378377
fn result_str(&mut self) -> ~str {
379378
let r = self.result_bytes();
380379
let mut s = ~"";
381-
for vec::each(r) |b| {
380+
for r.each |b| {
382381
s += uint::to_str_radix(*b as uint, 16u);
383382
}
384383
s
@@ -478,7 +477,7 @@ mod tests {
478477

479478
fn to_hex_str(r: &[u8, ..8]) -> ~str {
480479
let mut s = ~"";
481-
for vec::each(*r) |b| {
480+
for (*r).each |b| {
482481
s += uint::to_str_radix(*b as uint, 16u);
483482
}
484483
s

src/libcore/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
12001200
fn wb() -> c_int { O_WRONLY as c_int }
12011201

12021202
let mut fflags: c_int = wb();
1203-
for vec::each(flags) |f| {
1203+
for flags.each |f| {
12041204
match *f {
12051205
Append => fflags |= O_APPEND as c_int,
12061206
Create => fflags |= O_CREAT as c_int,

src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ mod tests {
14911491
fn test_env_getenv() {
14921492
let e = env();
14931493
assert!(vec::len(e) > 0u);
1494-
for vec::each(e) |p| {
1494+
for e.each |p| {
14951495
let (n, v) = copy *p;
14961496
debug!(copy n);
14971497
let v2 = getenv(n);
@@ -1583,7 +1583,7 @@ mod tests {
15831583
// Just assuming that we've got some contents in the current directory
15841584
assert!((vec::len(dirs) > 0u));
15851585
1586-
for vec::each(dirs) |dir| {
1586+
for dirs.each |dir| {
15871587
debug!(copy *dir);
15881588
}
15891589
}

src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
300300
ts: &[T], op: &fn(&T) -> Result<V,U>) -> Result<~[V],U> {
301301
302302
let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
303-
for vec::each(ts) |t| {
303+
for ts.each |t| {
304304
match op(t) {
305305
Ok(copy v) => vs.push(v),
306306
Err(copy u) => return Err(u)

src/libcore/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ fn with_argv<T>(prog: &str, args: &[~str],
426426
cb: &fn(**libc::c_char) -> T) -> T {
427427
let mut argptrs = str::as_c_str(prog, |b| ~[b]);
428428
let mut tmps = ~[];
429-
for vec::each(args) |arg| {
429+
for args.each |arg| {
430430
let t = @copy *arg;
431431
tmps.push(t);
432432
argptrs.push_all(str::as_c_str(*t, |b| ~[b]));
@@ -445,7 +445,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
445445
let mut tmps = ~[];
446446
let mut ptrs = ~[];
447447

448-
for vec::each(*es) |e| {
448+
for (*es).each |e| {
449449
let (k,v) = copy *e;
450450
let t = @(fmt!("%s=%s", k, v));
451451
tmps.push(t);
@@ -470,7 +470,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
470470
match *env {
471471
Some(ref es) if !vec::is_empty(*es) => {
472472
let mut blk : ~[u8] = ~[];
473-
for vec::each(*es) |e| {
473+
for (*es).each |e| {
474474
let (k,v) = copy *e;
475475
let t = fmt!("%s=%s", k, v);
476476
let mut v : ~[u8] = ::cast::transmute(t);

src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub fn from_char(ch: char) -> ~str {
189189
pub fn from_chars(chs: &[char]) -> ~str {
190190
let mut buf = ~"";
191191
reserve(&mut buf, chs.len());
192-
for vec::each(chs) |ch| {
192+
for chs.each |ch| {
193193
push_char(&mut buf, *ch);
194194
}
195195
buf
@@ -326,7 +326,7 @@ pub fn connect_slices(v: &[&str], sep: &str) -> ~str {
326326
do as_buf(sep) |sepbuf, seplen| {
327327
let seplen = seplen - 1;
328328
let mut buf = ::cast::transmute_mut_unsafe(buf);
329-
for vec::each(v) |ss| {
329+
for v.each |ss| {
330330
do as_buf(*ss) |ssbuf, sslen| {
331331
let sslen = sslen - 1;
332332
if first {
@@ -2407,7 +2407,7 @@ pub mod raw {
24072407
unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) {
24082408
let new_len = s.len() + bytes.len();
24092409
reserve_at_least(&mut *s, new_len);
2410-
for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); }
2410+
for bytes.each |byte| { push_byte(&mut *s, *byte); }
24112411
}
24122412

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

3785-
for vec::each(pairs) |p| {
3785+
for pairs.each |p| {
37863786
let (s, u) = copy *p;
37873787
assert!(to_utf16(s) == u);
37883788
assert!(from_utf16(u) == s);

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ fn encode_index<T>(ebml_w: &mut writer::Encoder,
10841084
for buckets.each |bucket| {
10851085
bucket_locs.push(ebml_w.writer.tell());
10861086
ebml_w.start_tag(tag_index_buckets_bucket);
1087-
for vec::each(**bucket) |elt| {
1087+
for (**bucket).each |elt| {
10881088
ebml_w.start_tag(tag_index_buckets_bucket_elt);
10891089
assert!(elt.pos < 0xffff_ffff);
10901090
writer.write_be_u32(elt.pos as u32);

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use core::hashmap::HashMap;
1717
use core::io::WriterUtil;
1818
use core::io;
1919
use core::uint;
20-
use core::vec;
2120
use syntax::abi::AbiSet;
2221
use syntax::ast;
2322
use syntax::ast::*;
@@ -398,7 +397,7 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
398397
}
399398

400399
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
401-
for vec::each(*bs) |bound| {
400+
for (*bs).each |bound| {
402401
match *bound {
403402
ty::bound_owned => w.write_char('S'),
404403
ty::bound_copy => w.write_char('C'),

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
366366
}
367367
let variants = ty::enum_variants(cx.tcx, eid);
368368
if found.len() != (*variants).len() {
369-
for vec::each(*variants) |v| {
369+
for (*variants).each |v| {
370370
if !found.contains(&(variant(v.id))) {
371371
return Some(variant(v.id));
372372
}

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn check_fn(
235235
}
236236

237237
fn check_arm(a: &arm, cx: Context, v: visit::vt<Context>) {
238-
for vec::each(a.pats) |p| {
238+
for a.pats.each |p| {
239239
do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _pth| {
240240
if mode == bind_by_copy {
241241
let t = ty::node_id_to_type(cx.tcx, id);

src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,7 @@ pub impl Resolver {
46304630
}
46314631
46324632
let mut smallest = 0;
4633-
for vec::eachi(maybes) |i, &other| {
4633+
for maybes.eachi |i, &other| {
46344634
46354635
values[i] = str::levdistance(name, other);
46364636
@@ -4664,7 +4664,7 @@ pub impl Resolver {
46644664
if item.id == node_id {
46654665
match item.node {
46664666
item_struct(class_def, _) => {
4667-
for vec::each(class_def.fields) |field| {
4667+
for class_def.fields.each |field| {
46684668
match field.node.kind {
46694669
unnamed_field => {},
46704670
named_field(ident, _) => {

src/librustc/middle/resolve_stage0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,7 +4681,7 @@ pub impl Resolver {
46814681
}
46824682
46834683
let mut smallest = 0;
4684-
for vec::eachi(maybes) |i, &other| {
4684+
for maybes.eachi |i, &other| {
46854685
46864686
values[i] = str::levdistance(name, other);
46874687
@@ -4715,7 +4715,7 @@ pub impl Resolver {
47154715
if item.id == node_id {
47164716
match item.node {
47174717
item_struct(class_def, _) => {
4718-
for vec::each(class_def.fields) |field| {
4718+
for class_def.fields.each |field| {
47194719
match field.node.kind {
47204720
unnamed_field => {},
47214721
named_field(ident, _) => {

src/librustc/middle/trans/_match.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub fn variant_opt(bcx: block, pat_id: ast::node_id)
283283
match ccx.tcx.def_map.get_copy(&pat_id) {
284284
ast::def_variant(enum_id, var_id) => {
285285
let variants = ty::enum_variants(ccx.tcx, enum_id);
286-
for vec::each(*variants) |v| {
286+
for (*variants).each |v| {
287287
if var_id == v.id {
288288
return var(v.disr_val,
289289
adt::represent_node(bcx, pat_id))
@@ -349,7 +349,7 @@ pub fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
349349
}
350350
351351
pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
352-
for vec::each(m) |br| {
352+
for m.each |br| {
353353
match br.pats[col].node {
354354
ast::pat_ident(_, _, Some(_)) => return true,
355355
_ => ()
@@ -418,7 +418,7 @@ pub fn enter_match<'r>(bcx: block,
418418
let _indenter = indenter();
419419
420420
let mut result = ~[];
421-
for vec::each(m) |br| {
421+
for m.each |br| {
422422
match e(br.pats[col]) {
423423
Some(sub) => {
424424
let pats =
@@ -934,7 +934,7 @@ pub fn collect_record_or_struct_fields(bcx: block,
934934
col: uint)
935935
-> ~[ast::ident] {
936936
let mut fields: ~[ast::ident] = ~[];
937-
for vec::each(m) |br| {
937+
for m.each |br| {
938938
match br.pats[col].node {
939939
ast::pat_struct(_, ref fs, _) => {
940940
match ty::get(node_id_type(bcx, br.pats[col].id)).sty {
@@ -973,7 +973,7 @@ pub fn root_pats_as_necessary(mut bcx: block,
973973
col: uint,
974974
val: ValueRef)
975975
-> block {
976-
for vec::each(m) |br| {
976+
for m.each |br| {
977977
let pat_id = br.pats[col].id;
978978
if pat_id != 0 {
979979
let datum = Datum {val: val, ty: node_id_type(bcx, pat_id),
@@ -1042,14 +1042,14 @@ pub fn pick_col(m: &[@Match]) -> uint {
10421042
}
10431043
}
10441044
let mut scores = vec::from_elem(m[0].pats.len(), 0u);
1045-
for vec::each(m) |br| {
1045+
for m.each |br| {
10461046
let mut i = 0u;
1047-
for vec::each(br.pats) |p| { scores[i] += score(*p); i += 1u; }
1047+
for br.pats.each |p| { scores[i] += score(*p); i += 1u; }
10481048
}
10491049
let mut max_score = 0u;
10501050
let mut best_col = 0u;
10511051
let mut i = 0u;
1052-
for vec::each(scores) |score| {
1052+
for scores.each |score| {
10531053
let score = *score;
10541054
10551055
// Irrefutable columns always go first, they'd only be duplicated in
@@ -1306,7 +1306,7 @@ pub fn compile_submatch(bcx: block,
13061306
let ccx = *bcx.fcx.ccx;
13071307
let mut pat_id = 0;
13081308
let mut pat_span = dummy_sp();
1309-
for vec::each(m) |br| {
1309+
for m.each |br| {
13101310
// Find a real id (we're adding placeholder wildcard patterns, but
13111311
// each column is guaranteed to have at least one real pattern)
13121312
if pat_id == 0 {
@@ -1438,7 +1438,7 @@ pub fn compile_submatch(bcx: block,
14381438
}
14391439
}
14401440
}
1441-
for vec::each(opts) |o| {
1441+
for opts.each |o| {
14421442
match *o {
14431443
range(_, _) => { kind = compare; break }
14441444
_ => ()
@@ -1460,7 +1460,7 @@ pub fn compile_submatch(bcx: block,
14601460
let mut i = 0u;
14611461
14621462
// Compile subtrees for each option
1463-
for vec::each(opts) |opt| {
1463+
for opts.each |opt| {
14641464
i += 1u;
14651465
let mut opt_cx = else_cx;
14661466
if !exhaustive || i < len {
@@ -1631,7 +1631,7 @@ pub fn trans_match_inner(scope_cx: block,
16311631
}
16321632
16331633
let mut arm_datas = ~[], matches = ~[];
1634-
for vec::each(arms) |arm| {
1634+
for arms.each |arm| {
16351635
let body = scope_block(bcx, arm.body.info(), ~"case_body");
16361636
16371637
// Create the bindings map, which is a mapping from each binding name
@@ -1670,7 +1670,7 @@ pub fn trans_match_inner(scope_cx: block,
16701670
arm: arm,
16711671
bindings_map: bindings_map};
16721672
arm_datas.push(arm_data);
1673-
for vec::each(arm.pats) |p| {
1673+
for arm.pats.each |p| {
16741674
matches.push(@Match {pats: ~[*p], data: arm_data});
16751675
}
16761676
}
@@ -1793,7 +1793,7 @@ pub fn bind_irrefutable_pat(bcx: block,
17931793
vinfo.disr_val,
17941794
val);
17951795
for sub_pats.each |sub_pat| {
1796-
for vec::eachi(args.vals) |i, argval| {
1796+
for args.vals.eachi |i, argval| {
17971797
bcx = bind_irrefutable_pat(bcx,
17981798
sub_pat[i],
17991799
*argval,

0 commit comments

Comments
 (0)