From fad7857c7b2c42da6081e593ab92d03d88643c81 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 7 Aug 2013 19:21:36 -0700 Subject: [PATCH] Mass rename of .consume{,_iter}() to .move_iter() cc #7887 --- src/libextra/dlist.rs | 28 ++++++------- src/libextra/json.rs | 6 +-- src/libextra/par.rs | 2 +- src/libextra/smallintmap.rs | 10 ++--- src/libextra/sort.rs | 2 +- src/libextra/test.rs | 6 +-- src/libextra/treemap.rs | 8 ++-- src/librustc/back/link.rs | 2 +- src/librustc/driver/driver.rs | 4 +- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/lint.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/librustc/rustc.rs | 4 +- src/librustdoc/attr_parser.rs | 2 +- src/librusti/program.rs | 6 +-- src/librustpkg/workspace.rs | 2 +- src/libstd/at_vec.rs | 16 ++++---- src/libstd/either.rs | 2 +- src/libstd/hashmap.rs | 40 +++++++++---------- src/libstd/option.rs | 2 +- src/libstd/os.rs | 2 +- src/libstd/path.rs | 4 +- src/libstd/result.rs | 4 +- src/libstd/rt/kill.rs | 2 +- src/libstd/rt/mod.rs | 2 +- src/libstd/rt/select.rs | 6 +-- src/libstd/rt/test.rs | 2 +- src/libstd/task/spawn.rs | 10 ++--- src/libstd/unstable/extfmt.rs | 2 +- src/libstd/vec.rs | 40 +++++++++---------- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/fmt.rs | 2 +- src/libsyntax/ext/ifmt.rs | 4 +- src/libsyntax/fold.rs | 2 +- src/libsyntax/opt_vec.rs | 4 +- src/libsyntax/parse/parser.rs | 2 +- src/test/bench/graph500-bfs.rs | 6 +-- src/test/bench/shootout-k-nucleotide-pipes.rs | 4 +- src/test/bench/task-perf-one-million.rs | 6 +-- 41 files changed, 129 insertions(+), 129 deletions(-) diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs index b0839a55795..2158a90963b 100644 --- a/src/libextra/dlist.rs +++ b/src/libextra/dlist.rs @@ -63,7 +63,7 @@ pub struct MutDListIterator<'self, T> { /// DList consuming iterator #[deriving(Clone)] -pub struct ConsumeIterator { +pub struct MoveIterator { priv list: DList } @@ -391,14 +391,14 @@ impl DList { /// Consume the list into an iterator yielding elements by value #[inline] - pub fn consume_iter(self) -> ConsumeIterator { - ConsumeIterator{list: self} + pub fn move_iter(self) -> MoveIterator { + MoveIterator{list: self} } /// Consume the list into an iterator yielding elements by value, in reverse #[inline] - pub fn consume_rev_iter(self) -> Invert> { - self.consume_iter().invert() + pub fn move_rev_iter(self) -> Invert> { + self.move_iter().invert() } } @@ -557,7 +557,7 @@ impl<'self, A> ListInsertion for MutDListIterator<'self, A> { } } -impl Iterator for ConsumeIterator { +impl Iterator for MoveIterator { #[inline] fn next(&mut self) -> Option { self.list.pop_front() } @@ -567,7 +567,7 @@ impl Iterator for ConsumeIterator { } } -impl DoubleEndedIterator for ConsumeIterator { +impl DoubleEndedIterator for MoveIterator { #[inline] fn next_back(&mut self) -> Option { self.list.pop_back() } } @@ -721,7 +721,7 @@ mod tests { check_links(&m); let sum = v + u; assert_eq!(sum.len(), m.len()); - for elt in sum.consume_iter() { + for elt in sum.move_iter() { assert_eq!(m.pop_front(), Some(elt)) } } @@ -745,7 +745,7 @@ mod tests { check_links(&m); let sum = u + v; assert_eq!(sum.len(), m.len()); - for elt in sum.consume_iter() { + for elt in sum.move_iter() { assert_eq!(m.pop_front(), Some(elt)) } } @@ -770,7 +770,7 @@ mod tests { m.rotate_backward(); check_links(&m); m.push_front(9); check_links(&m); m.rotate_forward(); check_links(&m); - assert_eq!(~[3,9,5,1,2], m.consume_iter().collect()); + assert_eq!(~[3,9,5,1,2], m.move_iter().collect()); } #[test] @@ -900,7 +900,7 @@ mod tests { } check_links(&m); assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.consume_iter().collect::<~[int]>(), ~[-2,0,1,2,3,4,5,6,7,8,9,0,1]); + assert_eq!(m.move_iter().collect::<~[int]>(), ~[-2,0,1,2,3,4,5,6,7,8,9,0,1]); } #[test] @@ -911,7 +911,7 @@ mod tests { m.merge(n, |a, b| a <= b); assert_eq!(m.len(), len); check_links(&m); - let res = m.consume_iter().collect::<~[int]>(); + let res = m.move_iter().collect::<~[int]>(); assert_eq!(res, ~[-1, 0, 0, 0, 1, 3, 5, 6, 7, 2, 7, 7, 9]); } @@ -927,7 +927,7 @@ mod tests { m.push_back(4); m.insert_ordered(3); check_links(&m); - assert_eq!(~[2,3,4], m.consume_iter().collect::<~[int]>()); + assert_eq!(~[2,3,4], m.move_iter().collect::<~[int]>()); } #[test] @@ -1003,7 +1003,7 @@ mod tests { check_links(&m); let mut i = 0u; - for (a, &b) in m.consume_iter().zip(v.iter()) { + for (a, &b) in m.move_iter().zip(v.iter()) { i += 1; assert_eq!(a, b); } diff --git a/src/libextra/json.rs b/src/libextra/json.rs index ec9cb902d3d..2287384b53a 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -948,7 +948,7 @@ impl serialize::Decoder for Decoder { let name = match self.stack.pop() { String(s) => s, List(list) => { - for v in list.consume_rev_iter() { + for v in list.move_rev_iter() { self.stack.push(v); } match self.stack.pop() { @@ -1066,7 +1066,7 @@ impl serialize::Decoder for Decoder { let len = match self.stack.pop() { List(list) => { let len = list.len(); - for v in list.consume_rev_iter() { + for v in list.move_rev_iter() { self.stack.push(v); } len @@ -1086,7 +1086,7 @@ impl serialize::Decoder for Decoder { let len = match self.stack.pop() { Object(obj) => { let len = obj.len(); - for (key, value) in obj.consume_iter() { + for (key, value) in obj.move_iter() { self.stack.push(value); self.stack.push(String(key)); } diff --git a/src/libextra/par.rs b/src/libextra/par.rs index 4069c68e71c..bb79b5c8b95 100644 --- a/src/libextra/par.rs +++ b/src/libextra/par.rs @@ -77,7 +77,7 @@ fn map_slices( info!("num_tasks: %?", (num_tasks, futures.len())); assert_eq!(num_tasks, futures.len()); - do futures.consume_iter().transform |ys| { + do futures.move_iter().transform |ys| { let mut ys = ys; ys.get() }.collect() diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index a601270e8ec..a1f3cd4f548 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -152,12 +152,12 @@ impl SmallIntMap { } /// Empties the hash map, moving all values into the specified closure - pub fn consume(&mut self) + pub fn move_iter(&mut self) -> FilterMap<(uint, Option), (uint, V), - Enumerate>>> + Enumerate>>> { let values = replace(&mut self.v, ~[]); - values.consume_iter().enumerate().filter_map(|(i, v)| { + values.move_iter().enumerate().filter_map(|(i, v)| { v.map_move(|v| (i, v)) }) } @@ -452,11 +452,11 @@ mod test_map { } #[test] - fn test_consume() { + fn test_move_iter() { let mut m = SmallIntMap::new(); m.insert(1, ~2); let mut called = false; - for (k, v) in m.consume() { + for (k, v) in m.move_iter() { assert!(!called); called = true; assert_eq!(k, 1); diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index daafdbc3718..c7920e72708 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -893,7 +893,7 @@ mod tests { fn ile(x: &(&'static str), y: &(&'static str)) -> bool { // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary clone. + // to_ascii_move and to_str_move to not do a unnecessary clone. // (Actually, could just remove the to_str_* call, but needs an deriving(Ord) on // Ascii) let x = x.to_ascii().to_lower().to_str_ascii(); diff --git a/src/libextra/test.rs b/src/libextra/test.rs index bd811aa0f90..6adef685d95 100644 --- a/src/libextra/test.rs +++ b/src/libextra/test.rs @@ -698,7 +698,7 @@ fn run_tests(opts: &TestOpts, // All benchmarks run at the end, in serial. // (this includes metric fns) - for b in filtered_benchs_and_metrics.consume_iter() { + for b in filtered_benchs_and_metrics.move_iter() { callback(TeWait(b.desc.clone())); run_test(!opts.run_benchmarks, b, ch.clone()); let (test, result) = p.recv(); @@ -744,7 +744,7 @@ pub fn filter_tests( } } - filtered.consume_iter().filter_map(|x| filter_fn(x, filter_str)).collect() + filtered.move_iter().filter_map(|x| filter_fn(x, filter_str)).collect() }; // Maybe pull out the ignored test and unignore them @@ -762,7 +762,7 @@ pub fn filter_tests( None } }; - filtered.consume_iter().filter_map(|x| filter(x)).collect() + filtered.move_iter().filter_map(|x| filter(x)).collect() }; // Sort the tests alphabetically diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 4d898dfb2b4..6e63b74449f 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -213,13 +213,13 @@ impl TreeMap { } /// Get a lazy iterator that consumes the treemap. - pub fn consume_iter(self) -> TreeMapConsumeIterator { + pub fn move_iter(self) -> TreeMapMoveIterator { let TreeMap { root: root, length: length } = self; let stk = match root { None => ~[], Some(~tn) => ~[tn] }; - TreeMapConsumeIterator { + TreeMapMoveIterator { stack: stk, remaining: length } @@ -331,12 +331,12 @@ fn iter_traverse_complete<'a, K, V>(it: &mut TreeMapIterator<'a, K, V>) { } /// Lazy forward iterator over a map that consumes the map while iterating -pub struct TreeMapConsumeIterator { +pub struct TreeMapMoveIterator { priv stack: ~[TreeNode], priv remaining: uint } -impl Iterator<(K, V)> for TreeMapConsumeIterator { +impl Iterator<(K, V)> for TreeMapMoveIterator { #[inline] fn next(&mut self) -> Option<(K, V)> { while !self.stack.is_empty() { diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index fbe17fb0d1c..5da769a60d7 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -935,7 +935,7 @@ pub fn link_args(sess: Session, // Add all the link args for external crates. do cstore::iter_crate_data(cstore) |crate_num, _| { let link_args = csearch::get_link_args_for_crate(cstore, crate_num); - for link_arg in link_args.consume_iter() { + for link_arg in link_args.move_iter() { args.push(link_arg); } } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index e349502d143..dce632bd9d6 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -120,7 +120,7 @@ pub fn build_configuration(sess: Session, argv0: @str, input: &input) -> // Convert strings provided as --cfg [cfgspec] into a crate_cfg fn parse_cfgspecs(cfgspecs: ~[~str], demitter: diagnostic::Emitter) -> ast::CrateConfig { - do cfgspecs.consume_iter().transform |s| { + do cfgspecs.move_iter().transform |s| { let sess = parse::new_parse_sess(Some(demitter)); parse::parse_meta_from_source_str(@"cfgspec", s.to_managed(), ~[], sess) }.collect::() @@ -631,7 +631,7 @@ pub fn build_session_options(binary: @str, let level_name = lint::level_to_str(*level); // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. let level_short = level_name.slice_chars(0, 1); let level_short = level_short.to_ascii().to_upper().to_str_ascii(); let flags = vec::append(getopts::opt_strs(matches, level_short), diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index b909f70440a..8a7894efb91 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1204,7 +1204,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, } c::tag_table_capture_map => { let cvars = - at_vec::to_managed_consume( + at_vec::to_managed_move( val_dsr.read_to_vec( |val_dsr| val_dsr.read_capture_var(xcx))); dcx.maps.capture_map.insert(id, cvars); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index bbcb40df775..3a15cbe0f52 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -994,7 +994,7 @@ fn lint_session(cx: @mut Context) -> @visit::Visitor<()> { match cx.tcx.sess.lints.pop(&id) { None => {}, Some(l) => { - for (lint, span, msg) in l.consume_iter() { + for (lint, span, msg) in l.move_iter() { cx.span_lint(lint, span, msg) } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 7d892d97676..4d95909404e 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -5366,7 +5366,7 @@ impl Resolver { if idents.len() == 0 { return ~"???"; } - return self.idents_to_str(idents.consume_rev_iter().collect::<~[ast::ident]>()); + return self.idents_to_str(idents.move_rev_iter().collect::<~[ast::ident]>()); } pub fn dump_module(@mut self, module_: @mut Module) { diff --git a/src/librustc/rustc.rs b/src/librustc/rustc.rs index 0c476686af9..668aaff35bb 100644 --- a/src/librustc/rustc.rs +++ b/src/librustc/rustc.rs @@ -156,7 +156,7 @@ Available lint options: "); let lint_dict = lint::get_lint_dict(); - let mut lint_dict = lint_dict.consume() + let mut lint_dict = lint_dict.move_iter() .transform(|(k, v)| (v, k)) .collect::<~[(lint::LintSpec, &'static str)]>(); lint_dict.qsort(); @@ -173,7 +173,7 @@ Available lint options: padded(max_key, "name"), "default", "meaning"); printfln!(" %s %7.7s %s\n", padded(max_key, "----"), "-------", "-------"); - for (spec, name) in lint_dict.consume_iter() { + for (spec, name) in lint_dict.move_iter() { let name = name.replace("_", "-"); printfln!(" %s %7.7s %s", padded(max_key, name), diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs index f8eff69cc8f..f1d6b7285e8 100644 --- a/src/librustdoc/attr_parser.rs +++ b/src/librustdoc/attr_parser.rs @@ -41,7 +41,7 @@ pub fn parse_crate(attrs: ~[ast::Attribute]) -> CrateAttrs { } pub fn parse_desc(attrs: ~[ast::Attribute]) -> Option<~str> { - let doc_strs = do doc_metas(attrs).consume_iter().filter_map |meta| { + let doc_strs = do doc_metas(attrs).move_iter().filter_map |meta| { meta.value_str() }.collect::<~[@str]>(); if doc_strs.is_empty() { diff --git a/src/librusti/program.rs b/src/librusti/program.rs index d8a640bc19c..07af3012601 100644 --- a/src/librusti/program.rs +++ b/src/librusti/program.rs @@ -167,7 +167,7 @@ impl Program { } let newvars = util::replace(&mut self.newvars, HashMap::new()); - for (name, var) in newvars.consume() { + for (name, var) in newvars.move_iter() { self.local_vars.insert(name, var); } @@ -233,7 +233,7 @@ impl Program { pub fn consume_cache(&mut self) { let map = local_data::pop(tls_key).expect("tls is empty"); let cons_map = util::replace(map, HashMap::new()); - for (name, value) in cons_map.consume() { + for (name, value) in cons_map.move_iter() { match self.local_vars.find_mut(&name) { Some(v) => { v.data = (*value).clone(); } None => { fail!("unknown variable %s", name) } @@ -345,7 +345,7 @@ impl Program { // I'm not an @ pointer, so this has to be done outside. let cons_newvars = util::replace(newvars, HashMap::new()); - for (k, v) in cons_newvars.consume() { + for (k, v) in cons_newvars.move_iter() { self.newvars.insert(k, v); } diff --git a/src/librustpkg/workspace.rs b/src/librustpkg/workspace.rs index 3e0e08dfe2d..6ac959e4a32 100644 --- a/src/librustpkg/workspace.rs +++ b/src/librustpkg/workspace.rs @@ -37,7 +37,7 @@ pub fn each_pkg_parent_workspace(pkgid: &PkgId, action: &fn(&Path) -> bool) -> b } pub fn pkg_parent_workspaces(pkgid: &PkgId) -> ~[Path] { - rust_path().consume_iter() + rust_path().move_iter() .filter(|ws| workspace_contains_package_id(pkgid, ws)) .collect() } diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 786548c0642..c948074990a 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -141,11 +141,11 @@ pub fn from_elem(n_elts: uint, t: T) -> @[T] { * Creates and initializes an immutable managed vector by moving all the * elements from an owned vector. */ -pub fn to_managed_consume(v: ~[T]) -> @[T] { +pub fn to_managed_move(v: ~[T]) -> @[T] { let mut av = @[]; unsafe { raw::reserve(&mut av, v.len()); - for x in v.consume_iter() { + for x in v.move_iter() { raw::push(&mut av, x); } av @@ -331,12 +331,12 @@ mod test { } #[test] - fn test_to_managed_consume() { - assert_eq!(to_managed_consume::(~[]), @[]); - assert_eq!(to_managed_consume(~[true]), @[true]); - assert_eq!(to_managed_consume(~[1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]); - assert_eq!(to_managed_consume(~[~"abc", ~"123"]), @[~"abc", ~"123"]); - assert_eq!(to_managed_consume(~[~[42]]), @[~[42]]); + fn test_to_managed_move() { + assert_eq!(to_managed_move::(~[]), @[]); + assert_eq!(to_managed_move(~[true]), @[true]); + assert_eq!(to_managed_move(~[1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]); + assert_eq!(to_managed_move(~[~"abc", ~"123"]), @[~"abc", ~"123"]); + assert_eq!(to_managed_move(~[~[42]]), @[~[42]]); } #[test] diff --git a/src/libstd/either.rs b/src/libstd/either.rs index bb74d9b3ec4..132ebc72960 100644 --- a/src/libstd/either.rs +++ b/src/libstd/either.rs @@ -150,7 +150,7 @@ pub fn rights(eithers: &[Either]) -> ~[R] { pub fn partition(eithers: ~[Either]) -> (~[L], ~[R]) { let mut lefts: ~[L] = ~[]; let mut rights: ~[R] = ~[]; - for elt in eithers.consume_iter() { + for elt in eithers.move_iter() { match elt { Left(l) => lefts.push(l), Right(r) => rights.push(r) diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 84cba254dcf..e7b33ce80fa 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -159,8 +159,8 @@ impl HashMap { vec::from_fn(new_capacity, |_| None)); self.size = 0; - // consume_rev_iter is more efficient - for bucket in old_buckets.consume_rev_iter() { + // move_rev_iter is more efficient + for bucket in old_buckets.move_rev_iter() { self.insert_opt_bucket(bucket); } } @@ -470,9 +470,9 @@ impl HashMap { /// Creates a consuming iterator, that is, one that moves each key-value /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. - pub fn consume(self) -> HashMapConsumeIterator { - // `consume_rev_iter` is more efficient than `consume_iter` for vectors - HashMapConsumeIterator {iter: self.buckets.consume_rev_iter()} + pub fn move_iter(self) -> HashMapMoveIterator { + // `move_rev_iter` is more efficient than `move_iter` for vectors + HashMapMoveIterator {iter: self.buckets.move_rev_iter()} } } @@ -524,9 +524,9 @@ pub struct HashMapMutIterator<'self, K, V> { priv iter: vec::VecMutIterator<'self, Option>>, } -/// HashMap consume iterator -pub struct HashMapConsumeIterator { - priv iter: vec::ConsumeRevIterator>>, +/// HashMap move iterator +pub struct HashMapMoveIterator { + priv iter: vec::MoveRevIterator>>, } /// HashSet iterator @@ -535,9 +535,9 @@ pub struct HashSetIterator<'self, K> { priv iter: vec::VecIterator<'self, Option>>, } -/// HashSet consume iterator -pub struct HashSetConsumeIterator { - priv iter: vec::ConsumeRevIterator>>, +/// HashSet move iterator +pub struct HashSetMoveIterator { + priv iter: vec::MoveRevIterator>>, } impl<'self, K, V> Iterator<(&'self K, &'self V)> for HashMapIterator<'self, K, V> { @@ -566,7 +566,7 @@ impl<'self, K, V> Iterator<(&'self K, &'self mut V)> for HashMapMutIterator<'sel } } -impl Iterator<(K, V)> for HashMapConsumeIterator { +impl Iterator<(K, V)> for HashMapMoveIterator { #[inline] fn next(&mut self) -> Option<(K, V)> { for elt in self.iter { @@ -592,7 +592,7 @@ impl<'self, K> Iterator<&'self K> for HashSetIterator<'self, K> { } } -impl Iterator for HashSetConsumeIterator { +impl Iterator for HashSetMoveIterator { #[inline] fn next(&mut self) -> Option { for elt in self.iter { @@ -707,9 +707,9 @@ impl HashSet { /// Creates a consuming iterator, that is, one that moves each value out /// of the set in arbitrary order. The set cannot be used after calling /// this. - pub fn consume(self) -> HashSetConsumeIterator { - // `consume_rev_iter` is more efficient than `consume_iter` for vectors - HashSetConsumeIterator {iter: self.map.buckets.consume_rev_iter()} + pub fn move_iter(self) -> HashSetMoveIterator { + // `move_rev_iter` is more efficient than `move_iter` for vectors + HashSetMoveIterator {iter: self.map.buckets.move_rev_iter()} } /// Visit the values representing the difference @@ -881,7 +881,7 @@ mod test_map { } #[test] - fn test_consume() { + fn test_move_iter() { let hm = { let mut hm = HashMap::new(); @@ -891,7 +891,7 @@ mod test_map { hm }; - let v = hm.consume().collect::<~[(char, int)]>(); + let v = hm.move_iter().collect::<~[(char, int)]>(); assert!([('a', 1), ('b', 2)] == v || [('b', 2), ('a', 1)] == v); } @@ -1177,7 +1177,7 @@ mod test_set { } #[test] - fn test_consume() { + fn test_move_iter() { let hs = { let mut hs = HashSet::new(); @@ -1187,7 +1187,7 @@ mod test_set { hs }; - let v = hs.consume().collect::<~[char]>(); + let v = hs.move_iter().collect::<~[char]>(); assert!(['a', 'b'] == v || ['b', 'a'] == v); } } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 66b30d8dd03..c1999ae47d6 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -134,7 +134,7 @@ impl Option { /// Return a consuming iterator over the possibly contained value #[inline] - pub fn consume(self) -> OptionIterator { + pub fn move_iter(self) -> OptionIterator { OptionIterator{opt: self} } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 008d59d5376..9ade21a4ede 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -765,7 +765,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { strings } } - do get_list(p).consume_iter().filter |filename| { + do get_list(p).move_iter().filter |filename| { "." != *filename && ".." != *filename }.collect() } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 14844e24006..fb8f8fc7b67 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -961,7 +961,7 @@ impl GenericPath for WindowsPath { match self.filestem() { Some(stem) => { // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. match stem.to_ascii().to_lower().to_str_ascii() { ~"con" | ~"aux" | ~"com1" | ~"com2" | ~"com3" | ~"com4" | ~"lpt1" | ~"lpt2" | ~"lpt3" | ~"prn" | ~"nul" => true, @@ -1020,7 +1020,7 @@ impl GenericPath for WindowsPath { None => None, // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. Some(ref device) => Some(device.to_ascii().to_upper().to_str_ascii()) }, is_absolute: self.is_absolute, diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 3e429c6116d..9de5e69148a 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -94,7 +94,7 @@ impl Result { match *self { Ok(ref t) => Some(t), Err(*) => None, - }.consume() + }.move_iter() } /// Call a method based on a previous result @@ -108,7 +108,7 @@ impl Result { match *self { Ok(*) => None, Err(ref t) => Some(t), - }.consume() + }.move_iter() } /// Unwraps a result, yielding the content of an `Ok`. diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs index e07cb1425bf..26c6c9119a1 100644 --- a/src/libstd/rt/kill.rs +++ b/src/libstd/rt/kill.rs @@ -239,7 +239,7 @@ impl BlockedTask { }; // Even if the task was unkillable before, we use 'Killable' because // multiple pipes will have handles. It does not really mean killable. - handles.consume_iter().transform(|x| Killable(x)).collect() + handles.move_iter().transform(|x| Killable(x)).collect() } // This assertion has two flavours because the wake involves an atomic op. diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 348345f61fc..91297af5c93 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -391,7 +391,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int { rtdebug!("waiting for threads"); // Wait for schedulers - for thread in threads.consume_iter() { + for thread in threads.move_iter() { thread.join(); } diff --git a/src/libstd/rt/select.rs b/src/libstd/rt/select.rs index 0e8d26e9482..bde703af315 100644 --- a/src/libstd/rt/select.rs +++ b/src/libstd/rt/select.rs @@ -54,7 +54,7 @@ pub fn select(ports: &mut [A]) -> uint { let task_handles = task.make_selectable(ports.len()); for (index, (port, task_handle)) in - ports.mut_iter().zip(task_handles.consume_iter()).enumerate() { + ports.mut_iter().zip(task_handles.move_iter()).enumerate() { // If one of the ports has data by now, it will wake the handle. if port.block_on(sched, task_handle) { ready_index = index; @@ -128,7 +128,7 @@ mod test { let (ports, chans) = unzip(from_fn(num_ports, |_| oneshot::<()>())); let mut dead_chans = ~[]; let mut ports = ports; - for (i, chan) in chans.consume_iter().enumerate() { + for (i, chan) in chans.move_iter().enumerate() { if send_on_chans.contains(&i) { chan.send(()); } else { @@ -145,7 +145,7 @@ mod test { let (ports, chans) = unzip(from_fn(num_ports, |_| stream::<()>())); let mut dead_chans = ~[]; let mut ports = ports; - for (i, chan) in chans.consume_iter().enumerate() { + for (i, chan) in chans.move_iter().enumerate() { if send_on_chans.contains(&i) { chan.send(()); } else { diff --git a/src/libstd/rt/test.rs b/src/libstd/rt/test.rs index 92366d5187f..ca94468e1ad 100644 --- a/src/libstd/rt/test.rs +++ b/src/libstd/rt/test.rs @@ -232,7 +232,7 @@ pub fn run_in_mt_newsched_task(f: ~fn()) { } // Wait for schedulers - for thread in threads.consume_iter() { + for thread in threads.move_iter() { thread.join(); } } diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 1a38dfc3d88..10bac9325ab 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -79,7 +79,7 @@ use cast; use cell::Cell; use container::MutableMap; use comm::{Chan, GenericChan, oneshot}; -use hashmap::{HashSet, HashSetConsumeIterator}; +use hashmap::{HashSet, HashSetMoveIterator}; use local_data; use task::{Failure, SingleThreaded}; use task::{Success, TaskOpts, TaskResult}; @@ -141,8 +141,8 @@ impl TaskSet { assert!(was_present); } #[inline] - fn consume(self) -> HashSetConsumeIterator { - (*self).consume() + fn move_iter(self) -> HashSetMoveIterator { + (*self).move_iter() } } @@ -460,13 +460,13 @@ fn kill_taskgroup(state: TaskGroupInner, me: &TaskHandle, is_main: bool) { if newstate.is_some() { let TaskGroupData { members: members, descendants: descendants } = newstate.unwrap(); - for sibling in members.consume() { + for sibling in members.move_iter() { // Skip self - killing ourself won't do much good. if &sibling != me { RuntimeGlue::kill_task(sibling); } } - for child in descendants.consume() { + for child in descendants.move_iter() { assert!(&child != me); RuntimeGlue::kill_task(child); } diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs index d63f914bc73..7b1f0e8ced8 100644 --- a/src/libstd/unstable/extfmt.rs +++ b/src/libstd/unstable/extfmt.rs @@ -526,7 +526,7 @@ pub mod rt { TyHexLower => uint_to_str_prec(u, 16, prec), // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. TyHexUpper => { let s = uint_to_str_prec(u, 16, prec); s.to_ascii().to_upper().to_str_ascii() diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 0f6d94bb771..60abe65f94d 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -382,7 +382,7 @@ pub fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { pub fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[]; let mut us = ~[]; - for p in v.consume_iter() { + for p in v.move_iter() { let (t, u) = p; ts.push(t); us.push(u); @@ -1174,8 +1174,8 @@ impl<'self,T:Clone> ImmutableCopyableVector for &'self [T] { #[allow(missing_doc)] pub trait OwnedVector { - fn consume_iter(self) -> ConsumeIterator; - fn consume_rev_iter(self) -> ConsumeRevIterator; + fn move_iter(self) -> MoveIterator; + fn move_rev_iter(self) -> MoveRevIterator; fn reserve(&mut self, n: uint); fn reserve_at_least(&mut self, n: uint); @@ -1204,26 +1204,26 @@ impl OwnedVector for ~[T] { /// value out of the vector (from start to end). The vector cannot /// be used after calling this. /// - /// Note that this performs O(n) swaps, and so `consume_rev_iter` + /// Note that this performs O(n) swaps, and so `move_rev_iter` /// (which just calls `pop` repeatedly) is more efficient. /// /// # Examples /// /// ~~~ {.rust} /// let v = ~[~"a", ~"b"]; - /// for s in v.consume_iter() { + /// for s in v.move_iter() { /// // s has type ~str, not &~str /// println(s); /// } /// ~~~ - fn consume_iter(self) -> ConsumeIterator { - ConsumeIterator { v: self, idx: 0 } + fn move_iter(self) -> MoveIterator { + MoveIterator { v: self, idx: 0 } } /// Creates a consuming iterator that moves out of the vector in - /// reverse order. Also see `consume_iter`, however note that this + /// reverse order. Also see `move_iter`, however note that this /// is more efficient. - fn consume_rev_iter(self) -> ConsumeRevIterator { - ConsumeRevIterator { v: self } + fn move_rev_iter(self) -> MoveRevIterator { + MoveRevIterator { v: self } } /** @@ -1540,7 +1540,7 @@ impl OwnedVector for ~[T] { let mut lefts = ~[]; let mut rights = ~[]; - for elt in self.consume_iter() { + for elt in self.move_iter() { if f(&elt) { lefts.push(elt); } else { @@ -2281,12 +2281,12 @@ pub type MutRevIterator<'self, T> = Invert>; /// An iterator that moves out of a vector. #[deriving(Clone)] -pub struct ConsumeIterator { +pub struct MoveIterator { priv v: ~[T], priv idx: uint, } -impl Iterator for ConsumeIterator { +impl Iterator for MoveIterator { fn next(&mut self) -> Option { // this is peculiar, but is required for safety with respect // to dtors. It traverses the first half of the vec, and @@ -2308,11 +2308,11 @@ impl Iterator for ConsumeIterator { /// An iterator that moves out of a vector in reverse order. #[deriving(Clone)] -pub struct ConsumeRevIterator { +pub struct MoveRevIterator { priv v: ~[T] } -impl Iterator for ConsumeRevIterator { +impl Iterator for MoveRevIterator { fn next(&mut self) -> Option { self.v.pop_opt() } @@ -3323,17 +3323,17 @@ mod tests { } #[test] - fn test_consume_iterator() { + fn test_move_iterator() { use iterator::*; let xs = ~[1u,2,3,4,5]; - assert_eq!(xs.consume_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); + assert_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); } #[test] - fn test_consume_rev_iterator() { + fn test_move_rev_iterator() { use iterator::*; let xs = ~[1u,2,3,4,5]; - assert_eq!(xs.consume_rev_iter().fold(0, |a: uint, b: uint| 10*a + b), 54321); + assert_eq!(xs.move_rev_iter().fold(0, |a: uint, b: uint| 10*a + b), 54321); } #[test] @@ -3608,7 +3608,7 @@ mod tests { } assert_eq!(cnt, 8); - for f in v.consume_iter() { + for f in v.move_iter() { assert!(f == Foo); cnt += 1; } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 9a8a3bc25d8..0005180ef50 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -247,7 +247,7 @@ pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> { } pub fn public_methods(ms: ~[@method]) -> ~[@method] { - do ms.consume_iter().filter |m| { + do ms.move_iter().filter |m| { match m.vis { public => true, _ => false diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 9edd41152f7..d5150cd2ace 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -209,7 +209,7 @@ pub fn sort_meta_items(items: &[@MetaItem]) -> ~[@MetaItem] { } // There doesn't seem to be a more optimal way to do this - do v.consume_iter().transform |(_, m)| { + do v.move_iter().transform |(_, m)| { match m.node { MetaList(n, ref mis) => { @spanned { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index d81dca005b0..1902e510935 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -702,7 +702,7 @@ impl AstBuilder for @ExtCtxt { } fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant { - let args = tys.consume_iter().transform(|ty| { + let args = tys.move_iter().transform(|ty| { ast::variant_arg { ty: ty, id: self.next_id() } }).collect(); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 008545c9729..10f2055b5fb 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -269,7 +269,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, corresponding function in std::unstable::extfmt. Each function takes a buffer to insert data into along with the data being formatted. */ let npieces = pieces.len(); - for (i, pc) in pieces.consume_iter().enumerate() { + for (i, pc) in pieces.move_iter().enumerate() { match pc { /* Raw strings get appended via str::push_str */ PieceString(s) => { diff --git a/src/libsyntax/ext/ifmt.rs b/src/libsyntax/ext/ifmt.rs index 5cf5fdba632..de700466d9e 100644 --- a/src/libsyntax/ext/ifmt.rs +++ b/src/libsyntax/ext/ifmt.rs @@ -575,8 +575,8 @@ impl Context { Some(self.format_arg(e.span, Right(name), lname)); } - let args = names.consume_iter().transform(|a| a.unwrap()); - let mut args = locals.consume_iter().chain_(args); + let args = names.move_iter().transform(|a| a.unwrap()); + let mut args = locals.move_iter().chain_(args); // Next, build up the actual call to the sprintf function. let result = self.ecx.expr_call_global(self.fmtsp, ~[ diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 0a5bc000720..c1c63466221 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -176,7 +176,7 @@ pub fn fold_ty_param(tp: TyParam, pub fn fold_ty_params(tps: &OptVec, fld: @ast_fold) -> OptVec { let tps = /*bad*/ (*tps).clone(); - tps.map_consume(|tp| fold_ty_param(tp, fld)) + tps.map_move(|tp| fold_ty_param(tp, fld)) } pub fn fold_lifetime(l: &Lifetime, diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 10603751a06..3758a8db62a 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -57,10 +57,10 @@ impl OptVec { } } - fn map_consume(self, op: &fn(T) -> U) -> OptVec { + fn map_move(self, op: &fn(T) -> U) -> OptVec { match self { Empty => Empty, - Vec(v) => Vec(v.consume_iter().transform(op).collect()) + Vec(v) => Vec(v.move_iter().transform(op).collect()) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ddb0e3bfa68..d1916088a41 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4310,7 +4310,7 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false) ); - for ty in arg_tys.consume_iter() { + for ty in arg_tys.move_iter() { args.push(ast::variant_arg { ty: ty, id: self.get_id(), diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 2f4d763b84d..02aa5eae506 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -96,9 +96,9 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph { } } - do graph.consume_iter().transform |v| { + do graph.move_iter().transform |v| { let mut vec = ~[]; - for i in v.consume() { + for i in v.move_iter() { vec.push(i); } vec @@ -119,7 +119,7 @@ fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] { } } let mut vec = ~[]; - for i in keys.consume() { + for i in keys.move_iter() { vec.push(i); } return vec; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 8c4e9092ce0..49120eb789e 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -75,7 +75,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { unsafe { let b = str::raw::from_bytes(k); // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. buffer.push_str(fmt!("%s %0.3f\n", b.to_ascii().to_upper().to_str_ascii(), v)); } } @@ -86,7 +86,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { // given a map, search for the frequency of a pattern fn find(mm: &HashMap<~[u8], uint>, key: ~str) -> uint { // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use - // to_ascii_consume and to_str_consume to not do a unnecessary copy. + // to_ascii_move and to_str_move to not do a unnecessary copy. let key = key.to_ascii().to_lower().to_str_ascii(); match mm.find_equiv(&key.as_bytes()) { option::None => { return 0u; } diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index 7f986eab789..e0292aed168 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -28,20 +28,20 @@ fn calc(children: uint, parent_wait_chan: &Chan>>) { }; let child_start_chans: ~[Chan>] = - wait_ports.consume_iter().transform(|port| port.recv()).collect(); + wait_ports.move_iter().transform(|port| port.recv()).collect(); let (start_port, start_chan) = stream::>(); parent_wait_chan.send(start_chan); let parent_result_chan: Chan = start_port.recv(); let child_sum_ports: ~[Port] = - do child_start_chans.consume_iter().transform |child_start_chan| { + do child_start_chans.move_iter().transform |child_start_chan| { let (child_sum_port, child_sum_chan) = stream::(); child_start_chan.send(child_sum_chan); child_sum_port }.collect(); - let sum = child_sum_ports.consume_iter().fold(0, |sum, sum_port| sum + sum_port.recv() ); + let sum = child_sum_ports.move_iter().fold(0, |sum, sum_port| sum + sum_port.recv() ); parent_result_chan.send(sum + 1); }