From d22acb77b219f1abe7265ea3a6d88017523a2d7e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 2 Dec 2014 14:28:35 -0500 Subject: [PATCH] libstd: fix fallout --- src/libstd/collections/hash/map.rs | 23 +++++++++++++++++------ src/libstd/collections/hash/set.rs | 9 +++++---- src/libstd/path/posix.rs | 4 ++-- src/libstd/path/windows.rs | 8 ++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index a8dce232d26..97e0518a072 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -852,7 +852,9 @@ impl, V, S, H: Hasher> HashMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn keys(&self) -> Keys { - self.iter().map(|(k, _v)| k) + fn first((a, _): (A, B)) -> A { a } + + self.iter().map(first) } /// An iterator visiting all values in arbitrary order. @@ -874,7 +876,9 @@ impl, V, S, H: Hasher> HashMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn values(&self) -> Values { - self.iter().map(|(_k, v)| v) + fn second((_, b): (A, B)) -> B { b } + + self.iter().map(second) } /// An iterator visiting all key-value pairs in arbitrary order. @@ -946,8 +950,10 @@ impl, V, S, H: Hasher> HashMap { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn into_iter(self) -> MoveEntries { + fn last_two((_, b, c): (A, B, C)) -> (B, C) { (b, c) } + MoveEntries { - inner: self.table.into_iter().map(|(_, k, v)| (k, v)) + inner: self.table.into_iter().map(last_two) } } @@ -1316,7 +1322,12 @@ pub struct MutEntries<'a, K: 'a, V: 'a> { /// HashMap move iterator pub struct MoveEntries { - inner: iter::Map<'static, (SafeHash, K, V), (K, V), table::MoveEntries> + inner: iter::Map< + (SafeHash, K, V), + (K, V), + table::MoveEntries, + fn((SafeHash, K, V)) -> (K, V), + > } /// A view into a single occupied location in a HashMap @@ -1434,11 +1445,11 @@ impl<'a, K, V> VacantEntry<'a, K, V> { /// HashMap 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>; /// HashMap 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>; impl, V, S, H: Hasher + Default> FromIterator<(K, V)> for HashMap { fn from_iter>(iter: T) -> HashMap { diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index b3ccfdbb47c..5db7bd7fc48 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -277,7 +277,9 @@ impl, S, H: Hasher> HashSet { /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn into_iter(self) -> SetMoveItems { - self.map.into_iter().map(|(k, _)| k) + fn first((a, _): (A, B)) -> A { a } + + self.map.into_iter().map(first) } /// Visit the values representing the difference. @@ -611,11 +613,10 @@ impl, S, H: Hasher + Default> Default for HashSet { /// HashSet iterator pub type SetItems<'a, K> = - iter::Map<'static, (&'a K, &'a ()), &'a K, Entries<'a, K, ()>>; + iter::Map<(&'a K, &'a ()), &'a K, Entries<'a, K, ()>, fn((&'a K, &'a ())) -> &'a K>; /// HashSet move iterator -pub type SetMoveItems = - iter::Map<'static, (K, ()), K, MoveEntries>; +pub type SetMoveItems = iter::Map<(K, ()), K, MoveEntries, fn((K, ())) -> K>; // `Repeat` is used to feed the filter closure an explicit capture // of a reference to the other set diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 470e1b4dbb7..6cafedcad11 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -32,8 +32,8 @@ use super::{BytesContainer, GenericPath, GenericPathUnsafe}; pub type Components<'a> = Splits<'a, u8>; /// Iterator that yields successive components of a Path as Option<&str> -pub type StrComponents<'a> = Map<'a, &'a [u8], Option<&'a str>, - Components<'a>>; +pub type StrComponents<'a> = + Map<&'a [u8], Option<&'a str>, Components<'a>, fn(&[u8]) -> Option<&str>>; /// Represents a POSIX file path #[deriving(Clone)] diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index ea522536d22..c3242c9cead 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -38,12 +38,12 @@ use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe}; /// /// Each component is yielded as Option<&str> for compatibility with PosixPath, but /// every component in WindowsPath is guaranteed to be Some. -pub type StrComponents<'a> = Map<'a, &'a str, Option<&'a str>, - CharSplits<'a, char>>; +pub type StrComponents<'a> = + Map<&'a str, Option<&'a str>, CharSplits<'a, char>, fn(&'a str) -> Option<&'a str>>; /// Iterator that yields successive components of a Path as &[u8] -pub type Components<'a> = Map<'a, Option<&'a str>, &'a [u8], - StrComponents<'a>>; +pub type Components<'a> = + Map, &'a [u8], StrComponents<'a>, fn(Option<&str>) -> &[u8]>; /// Represents a Windows path // Notes for Windows path impl: