diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-03-11 10:08:33 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-03-23 19:57:30 -0400 |
| commit | 9330bae4bde720dbdf8d379bd5529a1bb7a6f1e9 (patch) | |
| tree | 969855cd9cb464c2a238151829cfaed3933ff7ed /src/libcollectionstest | |
| parent | 37601131a0ffc49e93b8797020429a980520171c (diff) | |
| download | rust-9330bae4bde720dbdf8d379bd5529a1bb7a6f1e9.tar.gz rust-9330bae4bde720dbdf8d379bd5529a1bb7a6f1e9.zip | |
Fallout from changing fn traits to use inheritance rather than bridge
impls. This is a [breaking-change] (for gated code) in that when you implement `Fn` (`FnMut`) you must also implement `FnOnce`. This commit demonstrates how to fix it.
Diffstat (limited to 'src/libcollectionstest')
| -rw-r--r-- | src/libcollectionstest/btree/set.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libcollectionstest/btree/set.rs b/src/libcollectionstest/btree/set.rs index 488f0d756d3..234cd6e0fd2 100644 --- a/src/libcollectionstest/btree/set.rs +++ b/src/libcollectionstest/btree/set.rs @@ -43,8 +43,6 @@ struct Counter<'a, 'b> { } impl<'a, 'b, 'c> FnMut<(&'c i32,)> for Counter<'a, 'b> { - type Output = bool; - extern "rust-call" fn call_mut(&mut self, (&x,): (&'c i32,)) -> bool { assert_eq!(x, self.expected[*self.i]); *self.i += 1; @@ -52,6 +50,14 @@ impl<'a, 'b, 'c> FnMut<(&'c i32,)> for Counter<'a, 'b> { } } +impl<'a, 'b, 'c> FnOnce<(&'c i32,)> for Counter<'a, 'b> { + type Output = bool; + + extern "rust-call" fn call_once(mut self, args: (&'c i32,)) -> bool { + self.call_mut(args) + } +} + fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where // FIXME Replace Counter with `Box<FnMut(_) -> _>` F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, Counter) -> bool, |
