about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-12-15 15:41:30 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-12-22 12:27:07 -0500
commit8fe9e4dff6d9d0fdd940835ae377edcb3754f8c1 (patch)
treef6a8b3551df4061a76323418007569709e34dcdf /src/libcollections
parent7f6177e64627110e5b9776bd5304d65806081390 (diff)
downloadrust-8fe9e4dff6d9d0fdd940835ae377edcb3754f8c1.tar.gz
rust-8fe9e4dff6d9d0fdd940835ae377edcb3754f8c1.zip
Insert coercions to fn pointer types required for the new types
post-unboxed-closure-conversion. This requires a fair amount of
annoying coercions because all the `map` etc types are defined
generically over the `F`, so the automatic coercions don't propagate;
this is compounded by the need to use `let` and not `as` due to
stage0. That said, this pattern is to a large extent temporary and
unusual.
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/btree/map.rs2
-rw-r--r--src/libcollections/btree/set.rs1
-rw-r--r--src/libcollections/vec_map.rs3
3 files changed, 6 insertions, 0 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 01096c1fd4e..778314f352c 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -1230,6 +1230,7 @@ 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> {
         fn first<A, B>((a, _): (A, B)) -> A { a }
+        let first: fn((&'a K, &'a V)) -> &'a K = first; // coerce to fn pointer
 
         Keys { inner: self.iter().map(first) }
     }
@@ -1251,6 +1252,7 @@ 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> {
         fn second<A, B>((_, b): (A, B)) -> B { b }
+        let second: fn((&'a K, &'a V)) -> &'a V = second; // coerce to fn pointer
 
         Values { inner: self.iter().map(second) }
     }
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index e4328a3cb20..4ab9c7a4fcd 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -126,6 +126,7 @@ impl<T> BTreeSet<T> {
     #[unstable = "matches collection reform specification, waiting for dust to settle"]
     pub fn into_iter(self) -> MoveItems<T> {
         fn first<A, B>((a, _): (A, B)) -> A { a }
+        let first: fn((T, ())) -> T = first; // coerce to fn pointer
 
         MoveItems { iter: self.map.into_iter().map(first) }
     }
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index 1babde6066d..553eae4d896 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -144,6 +144,7 @@ impl<V> VecMap<V> {
     #[unstable = "matches collection reform specification, waiting for dust to settle"]
     pub fn keys<'r>(&'r self) -> Keys<'r, V> {
         fn first<A, B>((a, _): (A, B)) -> A { a }
+        let first: fn((uint, &'r V)) -> uint = first; // coerce to fn pointer
 
         Keys { iter: self.iter().map(first) }
     }
@@ -153,6 +154,7 @@ impl<V> VecMap<V> {
     #[unstable = "matches collection reform specification, waiting for dust to settle"]
     pub fn values<'r>(&'r self) -> Values<'r, V> {
         fn second<A, B>((_, b): (A, B)) -> B { b }
+        let second: fn((uint, &'r V)) -> &'r V = second; // coerce to fn pointer
 
         Values { iter: self.iter().map(second) }
     }
@@ -239,6 +241,7 @@ impl<V> VecMap<V> {
         fn filter<A>((i, v): (uint, Option<A>)) -> Option<(uint, A)> {
             v.map(|v| (i, v))
         }
+        let filter: fn((uint, Option<V>)) -> Option<(uint, V)> = filter; // coerce to fn ptr
 
         let values = replace(&mut self.v, vec!());
         MoveItems { iter: values.into_iter().enumerate().filter_map(filter) }