From 2e496818a5433c9229b125117d78be906f73f5e7 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 2 Feb 2013 14:03:43 -0500 Subject: [PATCH] oldmap: get rid of the legacy each_key method --- src/libcargo/cargo.rc | 6 +++--- src/librustc/middle/typeck/coherence.rs | 2 +- src/librustc/rustc.rc | 2 +- src/libstd/oldmap.rs | 6 +----- src/libsyntax/parse/token.rs | 6 +++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index 93a4d3dc2bf..52addaa4fec 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo { need_dir(&c.libdir); need_dir(&c.bindir); - for sources.each_key |k| { + for sources.each_key_ref |&k| { let mut s = sources.get(k); load_source_packages(&c, s); sources.insert(k, s); @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &Cargo) { } pub fn sync(c: &Cargo) { - for c.sources.each_key |k| { + for c.sources.each_key_ref |&k| { let mut s = c.sources.get(k); sync_one(c, s); c.sources.insert(k, s); @@ -1686,7 +1686,7 @@ pub fn cmd_sources(c: &Cargo) { match action { ~"clear" => { - for c.sources.each_key |k| { + for c.sources.each_key_ref |&k| { c.sources.remove(k); } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 2ceb8dc93ef..5ad8fd4c820 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -417,7 +417,7 @@ pub impl CoherenceChecker { let coherence_info = &self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; - for extension_methods.each_key |trait_id| { + for extension_methods.each_key_ref |&trait_id| { self.check_implementation_coherence_of(trait_id); } } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 7abf020cbeb..e29fcf69ef9 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -177,7 +177,7 @@ Available lint options: let lint_dict = lint::get_lint_dict(); let mut max_key = 0; - for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); } + for lint_dict.each_key_ref |&k| { max_key = uint::max(k.len(), max_key); } fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 2ca3ca9346e..7fd8aabc2fb 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -320,10 +320,6 @@ pub mod chained { self.each_ref(|k, v| blk(*k, *v)) } - pure fn each_key(blk: fn(key: K) -> bool) { - self.each_key_ref(|p| blk(*p)) - } - pure fn each_ref(blk: fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } @@ -407,7 +403,7 @@ pub fn set_add(set: Set, key: K) -> bool { /// Convert a set into a vector. pub pure fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.len()) |push| { - for s.each_key() |k| { + for s.each_key_ref() |&k| { push(k); } } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 6897068a6bf..2770d823bf3 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -454,13 +454,13 @@ pub fn mk_fake_ident_interner() -> @ident_interner { */ pub fn keyword_table() -> HashMap<~str, ()> { let keywords = HashMap(); - for temporary_keyword_table().each_key |word| { + for temporary_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } - for strict_keyword_table().each_key |word| { + for strict_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } - for reserved_keyword_table().each_key |word| { + for reserved_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } keywords