libcollections: fix fallout

This commit is contained in:
Jorge Aparicio 2014-12-02 14:07:40 -05:00
parent 1646d10edc
commit f91d87e6a0
6 changed files with 43 additions and 22 deletions

View file

@ -107,10 +107,12 @@ pub struct MoveEntries<K, V> {
}
/// 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<K, V> BTreeMap<K, V> {
/// ```
#[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, B>((a, _): (A, B)) -> A { a }
self.iter().map(first)
}
/// Gets an iterator over the values of the map.
@ -1226,7 +1230,9 @@ impl<K, V> BTreeMap<K, V> {
/// ```
#[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<A, B>((_, b): (A, B)) -> B { b }
self.iter().map(second)
}
/// Return the number of elements in the map.

View file

@ -36,7 +36,8 @@ pub struct BTreeSet<T>{
pub type Items<'a, T> = Keys<'a, T, ()>;
/// An owning iterator over a BTreeSet's items.
pub type MoveItems<T> = iter::Map<'static, (T, ()), T, MoveEntries<T, ()>>;
pub type MoveItems<T> =
iter::Map<(T, ()), T, MoveEntries<T, ()>, 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<T> BTreeSet<T> {
/// 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<T> {
self.map.into_iter().map(|(k, _)| k)
fn first<A, B>((a, _): (A, B)) -> A { a }
self.map.into_iter().map(first)
}
}

View file

@ -234,7 +234,9 @@ impl<K: Ord, V> TreeMap<K, V> {
/// ```
#[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, B>((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<K: Ord, V> TreeMap<K, V> {
/// ```
#[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<A, B>((_, 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

View file

@ -205,7 +205,9 @@ impl<T: Ord> TreeSet<T> {
#[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveSetItems<T> {
self.map.into_iter().map(|(value, _)| value)
fn first<A, B>((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<T> = iter::Map<'static, (T, ()), T, MoveEntries<T, ()>>;
pub type MoveSetItems<T> = iter::Map<(T, ()), T, MoveEntries<T, ()>, fn((T, ())) -> T>;
/// A lazy iterator producing elements in the set difference (in-order).
pub struct DifferenceItems<'a, T:'a> {

View file

@ -197,14 +197,18 @@ impl<T> TrieMap<T> {
/// 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, B>((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<A, B>((_, 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}}

View file

@ -141,14 +141,18 @@ impl<V> VecMap<V> {
/// 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, B>((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<A, B>((_, 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<V> =