about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2014-12-05 16:16:07 -0500
committerJorge Aparicio <japaricious@gmail.com>2014-12-13 17:03:46 -0500
commit0d39fc01bf2b105abd323a8f8ebd59b60f2790e7 (patch)
tree22cd6809808f58d8ccca13696ab35119dbe3050d /src/libcollections
parent02e7389c5d3e7fd9dfec13f691a04cfff003205d (diff)
downloadrust-0d39fc01bf2b105abd323a8f8ebd59b60f2790e7.tar.gz
rust-0d39fc01bf2b105abd323a8f8ebd59b60f2790e7.zip
libcollections: use unboxed closures in `TreeMap` methods
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/tree/map.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs
index 95fddb6ee11..5c2cf4a8180 100644
--- a/src/libcollections/tree/map.rs
+++ b/src/libcollections/tree/map.rs
@@ -616,7 +616,7 @@ impl<K, V> TreeMap<K, V> {
     /// ```
     #[inline]
     #[experimental = "likely to be renamed, may be removed"]
-    pub fn find_with(&self, f:|&K| -> Ordering) -> Option<&V> {
+    pub fn find_with<F>(&self, f: F) -> Option<&V> where F: FnMut(&K) -> Ordering {
         tree_find_with(&self.root, f)
     }
 
@@ -641,7 +641,9 @@ impl<K, V> TreeMap<K, V> {
     /// ```
     #[inline]
     #[experimental = "likely to be renamed, may be removed"]
-    pub fn find_with_mut<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> {
+    pub fn find_with_mut<'a, F>(&'a mut self, f: F) -> Option<&'a mut V> where
+        F: FnMut(&K) -> Ordering
+    {
         tree_find_with_mut(&mut self.root, f)
     }
 }
@@ -1129,8 +1131,12 @@ fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
 // Next 2 functions have the same convention: comparator gets
 // at input current key and returns search_key cmp cur_key
 // (i.e. search_key.cmp(&cur_key))
-fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
-                            f: |&K| -> Ordering) -> Option<&'r V> {
+fn tree_find_with<'r, K, V, F>(
+    node: &'r Option<Box<TreeNode<K, V>>>,
+    mut f: F,
+) -> Option<&'r V> where
+    F: FnMut(&K) -> Ordering,
+{
     let mut current: &'r Option<Box<TreeNode<K, V>>> = node;
     loop {
         match *current {
@@ -1147,8 +1153,12 @@ fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
 }
 
 // See comments above tree_find_with
-fn tree_find_with_mut<'r, K, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
-                                f: |&K| -> Ordering) -> Option<&'r mut V> {
+fn tree_find_with_mut<'r, K, V, F>(
+    node: &'r mut Option<Box<TreeNode<K, V>>>,
+    mut f: F,
+) -> Option<&'r mut V> where
+    F: FnMut(&K) -> Ordering,
+{
 
     let mut current = node;
     loop {