From f91d87e6a03f4e64034ee8fa073ac8d47e71dc88 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 2 Dec 2014 14:07:40 -0500 Subject: [PATCH] libcollections: fix fallout --- src/libcollections/btree/map.rs | 14 ++++++++++---- src/libcollections/btree/set.rs | 7 +++++-- src/libcollections/tree/map.rs | 12 ++++++++---- src/libcollections/tree/set.rs | 6 ++++-- src/libcollections/trie/map.rs | 13 ++++++++----- src/libcollections/vec_map.rs | 13 ++++++++----- 6 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 3d5067d5a516..e49a8ddbe5ab 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -107,10 +107,12 @@ pub struct MoveEntries { } /// An iterator over a BTreeMap's keys. -pub type Keys<'a, K, V> = iter::Map<'static, (&'a K, &'a V), &'a K, Entries<'a, K, V>>; +pub type Keys<'a, K, V> = + iter::Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>; /// An iterator over a BTreeMap's values. -pub type Values<'a, K, V> = iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>; +pub type Values<'a, K, V> = + iter::Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>; /// A view into a single entry in a map, which may either be vacant or occupied. pub enum Entry<'a, K:'a, V:'a> { @@ -1207,7 +1209,9 @@ impl BTreeMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn keys<'a>(&'a self) -> Keys<'a, K, V> { - self.iter().map(|(k, _)| k) + fn first((a, _): (A, B)) -> A { a } + + self.iter().map(first) } /// Gets an iterator over the values of the map. @@ -1226,7 +1230,9 @@ impl BTreeMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn values<'a>(&'a self) -> Values<'a, K, V> { - self.iter().map(|(_, v)| v) + fn second((_, b): (A, B)) -> B { b } + + self.iter().map(second) } /// Return the number of elements in the map. diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 0fbc319f4ff6..4289d42977b4 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -36,7 +36,8 @@ pub struct BTreeSet{ pub type Items<'a, T> = Keys<'a, T, ()>; /// An owning iterator over a BTreeSet's items. -pub type MoveItems = iter::Map<'static, (T, ()), T, MoveEntries>; +pub type MoveItems = + iter::Map<(T, ()), T, MoveEntries, fn((T, ())) -> T>; /// A lazy iterator producing elements in the set difference (in-order). pub struct DifferenceItems<'a, T:'a> { @@ -87,7 +88,9 @@ impl BTreeSet { /// Gets an iterator for moving out the BtreeSet's contents. #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn into_iter(self) -> MoveItems { - self.map.into_iter().map(|(k, _)| k) + fn first((a, _): (A, B)) -> A { a } + + self.map.into_iter().map(first) } } diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs index 24395ca64939..95fddb6ee114 100644 --- a/src/libcollections/tree/map.rs +++ b/src/libcollections/tree/map.rs @@ -234,7 +234,9 @@ impl TreeMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn keys<'a>(&'a self) -> Keys<'a, K, V> { - self.iter().map(|(k, _v)| k) + fn first((a, _): (A, B)) -> A { a } + + self.iter().map(first) } /// Gets a lazy iterator over the values in the map, in ascending order @@ -256,7 +258,9 @@ impl TreeMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn values<'a>(&'a self) -> Values<'a, K, V> { - self.iter().map(|(_k, v)| v) + fn second((_, b): (A, B)) -> B { b } + + self.iter().map(second) } /// Gets a lazy iterator over the key-value pairs in the map, in ascending order. @@ -863,11 +867,11 @@ pub struct RevMutEntries<'a, K:'a, V:'a> { /// TreeMap keys iterator. pub type Keys<'a, K, V> = - iter::Map<'static, (&'a K, &'a V), &'a K, Entries<'a, K, V>>; + iter::Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>; /// TreeMap values iterator. pub type Values<'a, K, V> = - iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>; + iter::Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>; // FIXME #5846 we want to be able to choose between &x and &mut x diff --git a/src/libcollections/tree/set.rs b/src/libcollections/tree/set.rs index 3af2f3e0193a..cee32619c810 100644 --- a/src/libcollections/tree/set.rs +++ b/src/libcollections/tree/set.rs @@ -205,7 +205,9 @@ impl TreeSet { #[inline] #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn into_iter(self) -> MoveSetItems { - self.map.into_iter().map(|(value, _)| value) + fn first((a, _): (A, B)) -> A { a } + + self.map.into_iter().map(first) } /// Gets a lazy iterator pointing to the first value not less than `v` (greater or equal). @@ -560,7 +562,7 @@ pub struct RevSetItems<'a, T:'a> { } /// A lazy forward iterator over a set that consumes the set while iterating. -pub type MoveSetItems = iter::Map<'static, (T, ()), T, MoveEntries>; +pub type MoveSetItems = iter::Map<(T, ()), T, MoveEntries, fn((T, ())) -> T>; /// A lazy iterator producing elements in the set difference (in-order). pub struct DifferenceItems<'a, T:'a> { diff --git a/src/libcollections/trie/map.rs b/src/libcollections/trie/map.rs index 1b087d2e63dd..a4dee8076487 100644 --- a/src/libcollections/trie/map.rs +++ b/src/libcollections/trie/map.rs @@ -197,14 +197,18 @@ impl TrieMap { /// The iterator's element type is `uint`. #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn keys<'r>(&'r self) -> Keys<'r, T> { - self.iter().map(|(k, _v)| k) + fn first((a, _): (A, B)) -> A { a } + + self.iter().map(first) } /// Gets an iterator visiting all values in ascending order by the keys. /// The iterator's element type is `&'r T`. #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn values<'r>(&'r self) -> Values<'r, T> { - self.iter().map(|(_k, v)| v) + fn second((_, b): (A, B)) -> B { b } + + self.iter().map(second) } /// Gets an iterator over the key-value pairs in the map, ordered by keys. @@ -1091,12 +1095,11 @@ pub struct MutEntries<'a, T:'a> { } /// A forward iterator over the keys of a map. -pub type Keys<'a, T> = - iter::Map<'static, (uint, &'a T), uint, Entries<'a, T>>; +pub type Keys<'a, T> = iter::Map<(uint, &'a T), uint, Entries<'a, T>, fn((uint, &'a T)) -> uint>; /// A forward iterator over the values of a map. pub type Values<'a, T> = - iter::Map<'static, (uint, &'a T), &'a T, Entries<'a, T>>; + iter::Map<(uint, &'a T), &'a T, Entries<'a, T>, fn((uint, &'a T)) -> &'a T>; // FIXME #5846: see `addr!` above. macro_rules! item { ($i:item) => {$i}} diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 3b8c690e0474..9356c769d266 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -141,14 +141,18 @@ impl VecMap { /// The iterator's element type is `uint`. #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn keys<'r>(&'r self) -> Keys<'r, V> { - self.iter().map(|(k, _v)| k) + fn first((a, _): (A, B)) -> A { a } + + self.iter().map(first) } /// Returns an iterator visiting all values in ascending order by the keys. /// The iterator's element type is `&'r V`. #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn values<'r>(&'r self) -> Values<'r, V> { - self.iter().map(|(_k, v)| v) + fn second((_, b): (A, B)) -> B { b } + + self.iter().map(second) } /// Returns an iterator visiting all key-value pairs in ascending order by the keys. @@ -620,12 +624,11 @@ iterator!(impl MutEntries -> (uint, &'a mut V), as_mut) double_ended_iterator!(impl MutEntries -> (uint, &'a mut V), as_mut) /// Forward iterator over the keys of a map -pub type Keys<'a, V> = - iter::Map<'static, (uint, &'a V), uint, Entries<'a, V>>; +pub type Keys<'a, V> = iter::Map<(uint, &'a V), uint, Entries<'a, V>, fn((uint, &'a V)) -> uint>; /// Forward iterator over the values of a map pub type Values<'a, V> = - iter::Map<'static, (uint, &'a V), &'a V, Entries<'a, V>>; + iter::Map<(uint, &'a V), &'a V, Entries<'a, V>, fn((uint, &'a V)) -> &'a V>; /// Iterator over the key-value pairs of a map, the iterator consumes the map pub type MoveItems =