Skip to content

Commit 3626f45

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163245 b: refs/heads/snap-stage3 c: f91d87e h: refs/heads/master i: 163243: fa0ddf4 v: v3
1 parent 8bd22d3 commit 3626f45

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1646d10edc57ec82536d6253f866084beb69a73e
4+
refs/heads/snap-stage3: f91d87e6a03f4e64034ee8fa073ac8d47e71dc88
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcollections/btree/map.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ pub struct MoveEntries<K, V> {
107107
}
108108

109109
/// An iterator over a BTreeMap's keys.
110-
pub type Keys<'a, K, V> = iter::Map<'static, (&'a K, &'a V), &'a K, Entries<'a, K, V>>;
110+
pub type Keys<'a, K, V> =
111+
iter::Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>;
111112

112113
/// An iterator over a BTreeMap's values.
113-
pub type Values<'a, K, V> = iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
114+
pub type Values<'a, K, V> =
115+
iter::Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>;
114116

115117
/// A view into a single entry in a map, which may either be vacant or occupied.
116118
pub enum Entry<'a, K:'a, V:'a> {
@@ -1207,7 +1209,9 @@ impl<K, V> BTreeMap<K, V> {
12071209
/// ```
12081210
#[unstable = "matches collection reform specification, waiting for dust to settle"]
12091211
pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
1210-
self.iter().map(|(k, _)| k)
1212+
fn first<A, B>((a, _): (A, B)) -> A { a }
1213+
1214+
self.iter().map(first)
12111215
}
12121216

12131217
/// Gets an iterator over the values of the map.
@@ -1226,7 +1230,9 @@ impl<K, V> BTreeMap<K, V> {
12261230
/// ```
12271231
#[unstable = "matches collection reform specification, waiting for dust to settle"]
12281232
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
1229-
self.iter().map(|(_, v)| v)
1233+
fn second<A, B>((_, b): (A, B)) -> B { b }
1234+
1235+
self.iter().map(second)
12301236
}
12311237

12321238
/// Return the number of elements in the map.

branches/snap-stage3/src/libcollections/btree/set.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ pub struct BTreeSet<T>{
3636
pub type Items<'a, T> = Keys<'a, T, ()>;
3737

3838
/// An owning iterator over a BTreeSet's items.
39-
pub type MoveItems<T> = iter::Map<'static, (T, ()), T, MoveEntries<T, ()>>;
39+
pub type MoveItems<T> =
40+
iter::Map<(T, ()), T, MoveEntries<T, ()>, fn((T, ())) -> T>;
4041

4142
/// A lazy iterator producing elements in the set difference (in-order).
4243
pub struct DifferenceItems<'a, T:'a> {
@@ -87,7 +88,9 @@ impl<T> BTreeSet<T> {
8788
/// Gets an iterator for moving out the BtreeSet's contents.
8889
#[unstable = "matches collection reform specification, waiting for dust to settle"]
8990
pub fn into_iter(self) -> MoveItems<T> {
90-
self.map.into_iter().map(|(k, _)| k)
91+
fn first<A, B>((a, _): (A, B)) -> A { a }
92+
93+
self.map.into_iter().map(first)
9194
}
9295
}
9396

branches/snap-stage3/src/libcollections/tree/map.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ impl<K: Ord, V> TreeMap<K, V> {
234234
/// ```
235235
#[unstable = "matches collection reform specification, waiting for dust to settle"]
236236
pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
237-
self.iter().map(|(k, _v)| k)
237+
fn first<A, B>((a, _): (A, B)) -> A { a }
238+
239+
self.iter().map(first)
238240
}
239241

240242
/// Gets a lazy iterator over the values in the map, in ascending order
@@ -256,7 +258,9 @@ impl<K: Ord, V> TreeMap<K, V> {
256258
/// ```
257259
#[unstable = "matches collection reform specification, waiting for dust to settle"]
258260
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
259-
self.iter().map(|(_k, v)| v)
261+
fn second<A, B>((_, b): (A, B)) -> B { b }
262+
263+
self.iter().map(second)
260264
}
261265

262266
/// 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> {
863867

864868
/// TreeMap keys iterator.
865869
pub type Keys<'a, K, V> =
866-
iter::Map<'static, (&'a K, &'a V), &'a K, Entries<'a, K, V>>;
870+
iter::Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>;
867871

868872
/// TreeMap values iterator.
869873
pub type Values<'a, K, V> =
870-
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
874+
iter::Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>;
871875

872876

873877
// FIXME #5846 we want to be able to choose between &x and &mut x

branches/snap-stage3/src/libcollections/tree/set.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ impl<T: Ord> TreeSet<T> {
205205
#[inline]
206206
#[unstable = "matches collection reform specification, waiting for dust to settle"]
207207
pub fn into_iter(self) -> MoveSetItems<T> {
208-
self.map.into_iter().map(|(value, _)| value)
208+
fn first<A, B>((a, _): (A, B)) -> A { a }
209+
210+
self.map.into_iter().map(first)
209211
}
210212

211213
/// 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> {
560562
}
561563

562564
/// A lazy forward iterator over a set that consumes the set while iterating.
563-
pub type MoveSetItems<T> = iter::Map<'static, (T, ()), T, MoveEntries<T, ()>>;
565+
pub type MoveSetItems<T> = iter::Map<(T, ()), T, MoveEntries<T, ()>, fn((T, ())) -> T>;
564566

565567
/// A lazy iterator producing elements in the set difference (in-order).
566568
pub struct DifferenceItems<'a, T:'a> {

branches/snap-stage3/src/libcollections/trie/map.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,18 @@ impl<T> TrieMap<T> {
197197
/// The iterator's element type is `uint`.
198198
#[unstable = "matches collection reform specification, waiting for dust to settle"]
199199
pub fn keys<'r>(&'r self) -> Keys<'r, T> {
200-
self.iter().map(|(k, _v)| k)
200+
fn first<A, B>((a, _): (A, B)) -> A { a }
201+
202+
self.iter().map(first)
201203
}
202204

203205
/// Gets an iterator visiting all values in ascending order by the keys.
204206
/// The iterator's element type is `&'r T`.
205207
#[unstable = "matches collection reform specification, waiting for dust to settle"]
206208
pub fn values<'r>(&'r self) -> Values<'r, T> {
207-
self.iter().map(|(_k, v)| v)
209+
fn second<A, B>((_, b): (A, B)) -> B { b }
210+
211+
self.iter().map(second)
208212
}
209213

210214
/// Gets an iterator over the key-value pairs in the map, ordered by keys.
@@ -1091,12 +1095,11 @@ pub struct MutEntries<'a, T:'a> {
10911095
}
10921096

10931097
/// A forward iterator over the keys of a map.
1094-
pub type Keys<'a, T> =
1095-
iter::Map<'static, (uint, &'a T), uint, Entries<'a, T>>;
1098+
pub type Keys<'a, T> = iter::Map<(uint, &'a T), uint, Entries<'a, T>, fn((uint, &'a T)) -> uint>;
10961099

10971100
/// A forward iterator over the values of a map.
10981101
pub type Values<'a, T> =
1099-
iter::Map<'static, (uint, &'a T), &'a T, Entries<'a, T>>;
1102+
iter::Map<(uint, &'a T), &'a T, Entries<'a, T>, fn((uint, &'a T)) -> &'a T>;
11001103

11011104
// FIXME #5846: see `addr!` above.
11021105
macro_rules! item { ($i:item) => {$i}}

branches/snap-stage3/src/libcollections/vec_map.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,18 @@ impl<V> VecMap<V> {
141141
/// The iterator's element type is `uint`.
142142
#[unstable = "matches collection reform specification, waiting for dust to settle"]
143143
pub fn keys<'r>(&'r self) -> Keys<'r, V> {
144-
self.iter().map(|(k, _v)| k)
144+
fn first<A, B>((a, _): (A, B)) -> A { a }
145+
146+
self.iter().map(first)
145147
}
146148

147149
/// Returns an iterator visiting all values in ascending order by the keys.
148150
/// The iterator's element type is `&'r V`.
149151
#[unstable = "matches collection reform specification, waiting for dust to settle"]
150152
pub fn values<'r>(&'r self) -> Values<'r, V> {
151-
self.iter().map(|(_k, v)| v)
153+
fn second<A, B>((_, b): (A, B)) -> B { b }
154+
155+
self.iter().map(second)
152156
}
153157

154158
/// 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)
620624
double_ended_iterator!(impl MutEntries -> (uint, &'a mut V), as_mut)
621625

622626
/// Forward iterator over the keys of a map
623-
pub type Keys<'a, V> =
624-
iter::Map<'static, (uint, &'a V), uint, Entries<'a, V>>;
627+
pub type Keys<'a, V> = iter::Map<(uint, &'a V), uint, Entries<'a, V>, fn((uint, &'a V)) -> uint>;
625628

626629
/// Forward iterator over the values of a map
627630
pub type Values<'a, V> =
628-
iter::Map<'static, (uint, &'a V), &'a V, Entries<'a, V>>;
631+
iter::Map<(uint, &'a V), &'a V, Entries<'a, V>, fn((uint, &'a V)) -> &'a V>;
629632

630633
/// Iterator over the key-value pairs of a map, the iterator consumes the map
631634
pub type MoveItems<V> =

0 commit comments

Comments
 (0)