diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs index 95fddb6ee114..5c2cf4a81808 100644 --- a/src/libcollections/tree/map.rs +++ b/src/libcollections/tree/map.rs @@ -616,7 +616,7 @@ impl TreeMap { /// ``` #[inline] #[experimental = "likely to be renamed, may be removed"] - pub fn find_with(&self, f:|&K| -> Ordering) -> Option<&V> { + pub fn find_with(&self, f: F) -> Option<&V> where F: FnMut(&K) -> Ordering { tree_find_with(&self.root, f) } @@ -641,7 +641,9 @@ impl TreeMap { /// ``` #[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(node: &mut Box>) { // 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>>, - f: |&K| -> Ordering) -> Option<&'r V> { +fn tree_find_with<'r, K, V, F>( + node: &'r Option>>, + mut f: F, +) -> Option<&'r V> where + F: FnMut(&K) -> Ordering, +{ let mut current: &'r Option>> = node; loop { match *current { @@ -1147,8 +1153,12 @@ fn tree_find_with<'r, K, V>(node: &'r Option>>, } // See comments above tree_find_with -fn tree_find_with_mut<'r, K, V>(node: &'r mut Option>>, - f: |&K| -> Ordering) -> Option<&'r mut V> { +fn tree_find_with_mut<'r, K, V, F>( + node: &'r mut Option>>, + mut f: F, +) -> Option<&'r mut V> where + F: FnMut(&K) -> Ordering, +{ let mut current = node; loop {