Skip to content

Commit

Permalink
Mass rename of .consume{,_iter}() to .move_iter()
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Aug 10, 2013
1 parent f0fc9c9 commit fad7857
Show file tree
Hide file tree
Showing 41 changed files with 129 additions and 129 deletions.
28 changes: 14 additions & 14 deletions src/libextra/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct MutDListIterator<'self, T> {

/// DList consuming iterator
#[deriving(Clone)]
pub struct ConsumeIterator<T> {
pub struct MoveIterator<T> {
priv list: DList<T>
}

Expand Down Expand Up @@ -391,14 +391,14 @@ impl<T> DList<T> {

/// Consume the list into an iterator yielding elements by value
#[inline]
pub fn consume_iter(self) -> ConsumeIterator<T> {
ConsumeIterator{list: self}
pub fn move_iter(self) -> MoveIterator<T> {
MoveIterator{list: self}
}

/// Consume the list into an iterator yielding elements by value, in reverse
#[inline]
pub fn consume_rev_iter(self) -> Invert<ConsumeIterator<T>> {
self.consume_iter().invert()
pub fn move_rev_iter(self) -> Invert<MoveIterator<T>> {
self.move_iter().invert()
}
}

Expand Down Expand Up @@ -557,7 +557,7 @@ impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
}
}

impl<A> Iterator<A> for ConsumeIterator<A> {
impl<A> Iterator<A> for MoveIterator<A> {
#[inline]
fn next(&mut self) -> Option<A> { self.list.pop_front() }

Expand All @@ -567,7 +567,7 @@ impl<A> Iterator<A> for ConsumeIterator<A> {
}
}

impl<A> DoubleEndedIterator<A> for ConsumeIterator<A> {
impl<A> DoubleEndedIterator<A> for MoveIterator<A> {
#[inline]
fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
}
Expand Down Expand Up @@ -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))
}
}
Expand All @@ -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))
}
}
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]);
}

Expand All @@ -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]
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn map_slices<A:Clone + Send,B:Clone + Send>(
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()
Expand Down
10 changes: 5 additions & 5 deletions src/libextra/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ impl<V> SmallIntMap<V> {
}

/// 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<V>), (uint, V),
Enumerate<vec::ConsumeIterator<Option<V>>>>
Enumerate<vec::MoveIterator<Option<V>>>>
{
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))
})
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ impl<K: TotalOrd, V> TreeMap<K, V> {
}

/// Get a lazy iterator that consumes the treemap.
pub fn consume_iter(self) -> TreeMapConsumeIterator<K, V> {
pub fn move_iter(self) -> TreeMapMoveIterator<K, V> {
let TreeMap { root: root, length: length } = self;
let stk = match root {
None => ~[],
Some(~tn) => ~[tn]
};
TreeMapConsumeIterator {
TreeMapMoveIterator {
stack: stk,
remaining: length
}
Expand Down Expand Up @@ -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<K, V> {
pub struct TreeMapMoveIterator<K, V> {
priv stack: ~[TreeNode<K, V>],
priv remaining: uint
}

impl<K, V> Iterator<(K, V)> for TreeMapConsumeIterator<K,V> {
impl<K, V> Iterator<(K, V)> for TreeMapMoveIterator<K,V> {
#[inline]
fn next(&mut self) -> Option<(K, V)> {
while !self.stack.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ast::CrateConfig>()
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/attr_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/librusti/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 8 additions & 8 deletions src/libstd/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ pub fn from_elem<T:Clone>(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<T>(v: ~[T]) -> @[T] {
pub fn to_managed_move<T>(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
Expand Down Expand Up @@ -331,12 +331,12 @@ mod test {
}

#[test]
fn test_to_managed_consume() {
assert_eq!(to_managed_consume::<int>(~[]), @[]);
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::<int>(~[]), @[]);
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]
Expand Down
Loading

0 comments on commit fad7857

Please sign in to comment.