Skip to content

Commit d22acb7

Browse files
author
Jorge Aparicio
committed
libstd: fix fallout
1 parent 0fcd730 commit d22acb7

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

src/libstd/collections/hash/map.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,9 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
852852
/// ```
853853
#[unstable = "matches collection reform specification, waiting for dust to settle"]
854854
pub fn keys(&self) -> Keys<K, V> {
855-
self.iter().map(|(k, _v)| k)
855+
fn first<A, B>((a, _): (A, B)) -> A { a }
856+
857+
self.iter().map(first)
856858
}
857859

858860
/// An iterator visiting all values in arbitrary order.
@@ -874,7 +876,9 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
874876
/// ```
875877
#[unstable = "matches collection reform specification, waiting for dust to settle"]
876878
pub fn values(&self) -> Values<K, V> {
877-
self.iter().map(|(_k, v)| v)
879+
fn second<A, B>((_, b): (A, B)) -> B { b }
880+
881+
self.iter().map(second)
878882
}
879883

880884
/// An iterator visiting all key-value pairs in arbitrary order.
@@ -946,8 +950,10 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
946950
/// ```
947951
#[unstable = "matches collection reform specification, waiting for dust to settle"]
948952
pub fn into_iter(self) -> MoveEntries<K, V> {
953+
fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
954+
949955
MoveEntries {
950-
inner: self.table.into_iter().map(|(_, k, v)| (k, v))
956+
inner: self.table.into_iter().map(last_two)
951957
}
952958
}
953959

@@ -1316,7 +1322,12 @@ pub struct MutEntries<'a, K: 'a, V: 'a> {
13161322

13171323
/// HashMap move iterator
13181324
pub struct MoveEntries<K, V> {
1319-
inner: iter::Map<'static, (SafeHash, K, V), (K, V), table::MoveEntries<K, V>>
1325+
inner: iter::Map<
1326+
(SafeHash, K, V),
1327+
(K, V),
1328+
table::MoveEntries<K, V>,
1329+
fn((SafeHash, K, V)) -> (K, V),
1330+
>
13201331
}
13211332

13221333
/// A view into a single occupied location in a HashMap
@@ -1434,11 +1445,11 @@ impl<'a, K, V> VacantEntry<'a, K, V> {
14341445

14351446
/// HashMap keys iterator
14361447
pub type Keys<'a, K, V> =
1437-
iter::Map<'static, (&'a K, &'a V), &'a K, Entries<'a, K, V>>;
1448+
iter::Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>;
14381449

14391450
/// HashMap values iterator
14401451
pub type Values<'a, K, V> =
1441-
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
1452+
iter::Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>;
14421453

14431454
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
14441455
fn from_iter<T: Iterator<(K, V)>>(iter: T) -> HashMap<K, V, H> {

src/libstd/collections/hash/set.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
277277
/// ```
278278
#[unstable = "matches collection reform specification, waiting for dust to settle"]
279279
pub fn into_iter(self) -> SetMoveItems<T> {
280-
self.map.into_iter().map(|(k, _)| k)
280+
fn first<A, B>((a, _): (A, B)) -> A { a }
281+
282+
self.map.into_iter().map(first)
281283
}
282284

283285
/// Visit the values representing the difference.
@@ -611,11 +613,10 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> {
611613

612614
/// HashSet iterator
613615
pub type SetItems<'a, K> =
614-
iter::Map<'static, (&'a K, &'a ()), &'a K, Entries<'a, K, ()>>;
616+
iter::Map<(&'a K, &'a ()), &'a K, Entries<'a, K, ()>, fn((&'a K, &'a ())) -> &'a K>;
615617

616618
/// HashSet move iterator
617-
pub type SetMoveItems<K> =
618-
iter::Map<'static, (K, ()), K, MoveEntries<K, ()>>;
619+
pub type SetMoveItems<K> = iter::Map<(K, ()), K, MoveEntries<K, ()>, fn((K, ())) -> K>;
619620

620621
// `Repeat` is used to feed the filter closure an explicit capture
621622
// of a reference to the other set

src/libstd/path/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use super::{BytesContainer, GenericPath, GenericPathUnsafe};
3232
pub type Components<'a> = Splits<'a, u8>;
3333

3434
/// Iterator that yields successive components of a Path as Option<&str>
35-
pub type StrComponents<'a> = Map<'a, &'a [u8], Option<&'a str>,
36-
Components<'a>>;
35+
pub type StrComponents<'a> =
36+
Map<&'a [u8], Option<&'a str>, Components<'a>, fn(&[u8]) -> Option<&str>>;
3737

3838
/// Represents a POSIX file path
3939
#[deriving(Clone)]

src/libstd/path/windows.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe};
3838
///
3939
/// Each component is yielded as Option<&str> for compatibility with PosixPath, but
4040
/// every component in WindowsPath is guaranteed to be Some.
41-
pub type StrComponents<'a> = Map<'a, &'a str, Option<&'a str>,
42-
CharSplits<'a, char>>;
41+
pub type StrComponents<'a> =
42+
Map<&'a str, Option<&'a str>, CharSplits<'a, char>, fn(&'a str) -> Option<&'a str>>;
4343

4444
/// Iterator that yields successive components of a Path as &[u8]
45-
pub type Components<'a> = Map<'a, Option<&'a str>, &'a [u8],
46-
StrComponents<'a>>;
45+
pub type Components<'a> =
46+
Map<Option<&'a str>, &'a [u8], StrComponents<'a>, fn(Option<&str>) -> &[u8]>;
4747

4848
/// Represents a Windows path
4949
// Notes for Windows path impl:

0 commit comments

Comments
 (0)