Skip to content

Commit 7cae944

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163774 b: refs/heads/master c: 0d39fc0 h: refs/heads/master v: v3
1 parent 0febdaf commit 7cae944

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 02e7389c5d3e7fd9dfec13f691a04cfff003205d
2+
refs/heads/master: 0d39fc01bf2b105abd323a8f8ebd59b60f2790e7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8443b09e361b96d1f9b7f45a65ed0d31c0e86e70
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42

trunk/src/libcollections/tree/map.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl<K, V> TreeMap<K, V> {
616616
/// ```
617617
#[inline]
618618
#[experimental = "likely to be renamed, may be removed"]
619-
pub fn find_with(&self, f:|&K| -> Ordering) -> Option<&V> {
619+
pub fn find_with<F>(&self, f: F) -> Option<&V> where F: FnMut(&K) -> Ordering {
620620
tree_find_with(&self.root, f)
621621
}
622622

@@ -641,7 +641,9 @@ impl<K, V> TreeMap<K, V> {
641641
/// ```
642642
#[inline]
643643
#[experimental = "likely to be renamed, may be removed"]
644-
pub fn find_with_mut<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> {
644+
pub fn find_with_mut<'a, F>(&'a mut self, f: F) -> Option<&'a mut V> where
645+
F: FnMut(&K) -> Ordering
646+
{
645647
tree_find_with_mut(&mut self.root, f)
646648
}
647649
}
@@ -1129,8 +1131,12 @@ fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
11291131
// Next 2 functions have the same convention: comparator gets
11301132
// at input current key and returns search_key cmp cur_key
11311133
// (i.e. search_key.cmp(&cur_key))
1132-
fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
1133-
f: |&K| -> Ordering) -> Option<&'r V> {
1134+
fn tree_find_with<'r, K, V, F>(
1135+
node: &'r Option<Box<TreeNode<K, V>>>,
1136+
mut f: F,
1137+
) -> Option<&'r V> where
1138+
F: FnMut(&K) -> Ordering,
1139+
{
11341140
let mut current: &'r Option<Box<TreeNode<K, V>>> = node;
11351141
loop {
11361142
match *current {
@@ -1147,8 +1153,12 @@ fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
11471153
}
11481154

11491155
// See comments above tree_find_with
1150-
fn tree_find_with_mut<'r, K, V>(node: &'r mut Option<Box<TreeNode<K, V>>>,
1151-
f: |&K| -> Ordering) -> Option<&'r mut V> {
1156+
fn tree_find_with_mut<'r, K, V, F>(
1157+
node: &'r mut Option<Box<TreeNode<K, V>>>,
1158+
mut f: F,
1159+
) -> Option<&'r mut V> where
1160+
F: FnMut(&K) -> Ordering,
1161+
{
11521162

11531163
let mut current = node;
11541164
loop {

0 commit comments

Comments
 (0)