summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-02-07 17:49:57 -0500
committerDaniel Micay <danielmicay@gmail.com>2013-02-07 22:04:35 -0500
commit83270d2d792fb519481f6df87f23d73c767ec5f9 (patch)
tree89b8242df68a8a249291c6a2b5354bc7de2f0bac /src/test
parentd903231f1e7d7efb35405bdfdcbc451385e429b2 (diff)
downloadrust-83270d2d792fb519481f6df87f23d73c767ec5f9.tar.gz
rust-83270d2d792fb519481f6df87f23d73c767ec5f9.zip
rm each method from the Map trait
the map types should implement BaseIter instead
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/class-impl-very-parameterized-trait.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs
index b7c8322316f..a0230d02981 100644
--- a/src/test/run-pass/class-impl-very-parameterized-trait.rs
+++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs
@@ -11,6 +11,7 @@
 // xfail-fast
 
 use core::container::{Container, Mutable, Map};
+use core::iter::BaseIter;
 
 enum cat_type { tuxedo, tabby, tortoiseshell }
 
@@ -48,6 +49,18 @@ impl<T> cat<T> {
     }
 }
 
+impl<T> cat<T>: BaseIter<(int, &T)> {
+    pure fn each(&self, f: fn(&(int, &self/T)) -> bool) {
+        let mut n = int::abs(self.meows);
+        while n > 0 {
+            if !f(&(n, &self.name)) { break; }
+            n -= 1;
+        }
+    }
+
+    pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
+}
+
 impl<T> cat<T>: Container {
     pure fn len(&self) -> uint { self.meows as uint }
     pure fn is_empty(&self) -> bool { self.meows == 0 }
@@ -60,20 +73,12 @@ impl<T> cat<T>: Mutable {
 impl<T> cat<T>: Map<int, T> {
     pure fn contains_key(&self, k: &int) -> bool { *k <= self.meows }
 
-    pure fn each(&self, f: fn(v: &int, v: &T) -> bool) {
-        let mut n = int::abs(self.meows);
-        while n > 0 {
-            if !f(&n, &self.name) { break; }
-            n -= 1;
-        }
-    }
-
     pure fn each_key(&self, f: fn(v: &int) -> bool) {
-        for self.each |k, _| { if !f(k) { break; } loop;};
+        for self.each |&(k, _)| { if !f(&k) { break; } loop;};
     }
 
     pure fn each_value(&self, f: fn(v: &T) -> bool) {
-        for self.each |_, v| { if !f(v) { break; } loop;};
+        for self.each |&(_, v)| { if !f(v) { break; } loop;};
     }
 
     fn insert(&mut self, k: int, _: T) -> bool {