Skip to content

Commit 0d38642

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 164741 b: refs/heads/try c: b3cd056 h: refs/heads/master i: 164739: 4c01702 v: v3
1 parent ede9b90 commit 0d38642

File tree

4 files changed

+55
-28
lines changed

4 files changed

+55
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f8f2c7a9537c7f333b242f616aefb75a83860927
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8443b09e361b96d1f9b7f45a65ed0d31c0e86e70
5-
refs/heads/try: 10a14d5f04e958918ae3cd3e3a2ef881e5dc0a6d
5+
refs/heads/try: b3cd05642c98feccee93295a14efa933776cf3e6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcollections/btree/set.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,22 +603,31 @@ mod test {
603603
assert!(hash::hash(&x) == hash::hash(&y));
604604
}
605605

606-
fn check(a: &[int],
607-
b: &[int],
608-
expected: &[int],
609-
f: |&BTreeSet<int>, &BTreeSet<int>, f: |&int| -> bool| -> bool) {
606+
struct Counter<'a, 'b> {
607+
i: &'a mut uint,
608+
expected: &'b [int],
609+
}
610+
611+
impl<'a, 'b> FnMut(&int) -> bool for Counter<'a, 'b> {
612+
extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {
613+
assert_eq!(x, self.expected[*self.i]);
614+
*self.i += 1;
615+
true
616+
}
617+
}
618+
619+
fn check<F>(a: &[int], b: &[int], expected: &[int], f: F) where
620+
// FIXME Replace Counter with `Box<FnMut(_) -> _>`
621+
F: FnOnce(&BTreeSet<int>, &BTreeSet<int>, Counter) -> bool,
622+
{
610623
let mut set_a = BTreeSet::new();
611624
let mut set_b = BTreeSet::new();
612625

613626
for x in a.iter() { assert!(set_a.insert(*x)) }
614627
for y in b.iter() { assert!(set_b.insert(*y)) }
615628

616629
let mut i = 0;
617-
f(&set_a, &set_b, |x| {
618-
assert_eq!(*x, expected[i]);
619-
i += 1;
620-
true
621-
});
630+
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
622631
assert_eq!(i, expected.len());
623632
}
624633

branches/try/src/libcollections/tree/set.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -936,22 +936,31 @@ mod test {
936936
assert!(hash::hash(&x) == hash::hash(&y));
937937
}
938938

939-
fn check(a: &[int],
940-
b: &[int],
941-
expected: &[int],
942-
f: |&TreeSet<int>, &TreeSet<int>, f: |&int| -> bool| -> bool) {
939+
struct Counter<'a, 'b> {
940+
i: &'a mut uint,
941+
expected: &'b [int],
942+
}
943+
944+
impl<'a, 'b> FnMut(&int) -> bool for Counter<'a, 'b> {
945+
extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {
946+
assert_eq!(x, self.expected[*self.i]);
947+
*self.i += 1;
948+
true
949+
}
950+
}
951+
952+
fn check<F>(a: &[int], b: &[int], expected: &[int], f: F) where
953+
// FIXME Replace `Counter` with `Box<FnMut(&int) -> bool>`
954+
F: FnOnce(&TreeSet<int>, &TreeSet<int>, Counter) -> bool,
955+
{
943956
let mut set_a = TreeSet::new();
944957
let mut set_b = TreeSet::new();
945958

946959
for x in a.iter() { assert!(set_a.insert(*x)) }
947960
for y in b.iter() { assert!(set_b.insert(*y)) }
948961

949962
let mut i = 0;
950-
f(&set_a, &set_b, |x| {
951-
assert_eq!(*x, expected[i]);
952-
i += 1;
953-
true
954-
});
963+
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
955964
assert_eq!(i, expected.len());
956965
}
957966

branches/try/src/libcollections/trie/set.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,22 +743,31 @@ mod test {
743743
assert!(a < b && a <= b);
744744
}
745745

746-
fn check(a: &[uint],
747-
b: &[uint],
748-
expected: &[uint],
749-
f: |&TrieSet, &TrieSet, f: |uint| -> bool| -> bool) {
746+
struct Counter<'a, 'b> {
747+
i: &'a mut uint,
748+
expected: &'b [uint],
749+
}
750+
751+
impl<'a, 'b> FnMut(uint) -> bool for Counter<'a, 'b> {
752+
extern "rust-call" fn call_mut(&mut self, (x,): (uint,)) -> bool {
753+
assert_eq!(x, self.expected[*self.i]);
754+
*self.i += 1;
755+
true
756+
}
757+
}
758+
759+
fn check<F>(a: &[uint], b: &[uint], expected: &[uint], f: F) where
760+
// FIXME Replace `Counter` with `Box<FnMut(&uint) -> bool>`
761+
F: FnOnce(&TrieSet, &TrieSet, Counter) -> bool,
762+
{
750763
let mut set_a = TrieSet::new();
751764
let mut set_b = TrieSet::new();
752765

753766
for x in a.iter() { assert!(set_a.insert(*x)) }
754767
for y in b.iter() { assert!(set_b.insert(*y)) }
755768

756769
let mut i = 0;
757-
f(&set_a, &set_b, |x| {
758-
assert_eq!(x, expected[i]);
759-
i += 1;
760-
true
761-
});
770+
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
762771
assert_eq!(i, expected.len());
763772
}
764773

0 commit comments

Comments
 (0)