]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / foreach-external-iterators-hashmap-break-restart.rs
index 4b6421cb0d3ce354b1c2a675c281d3652fa84f4e..4305ae956989e3e99e44cb70f3db18ee82c89f45 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::hashmap::HashMap;
+extern crate collections;
+
+use std::collections::HashMap;
 
 // This is a fancy one: it uses an external iterator established
 // outside the loop, breaks, then _picks back up_ and continues
 // iterating with it.
 
-fn main() {
+pub fn main() {
     let mut h = HashMap::new();
-    let kvs = [(1, 10), (2, 20), (3, 30)];
-    foreach &(k,v) in kvs.iter() {
+    let kvs = [(1i, 10i), (2i, 20i), (3i, 30i)];
+    for &(k,v) in kvs.iter() {
         h.insert(k,v);
     }
     let mut x = 0;
@@ -25,17 +27,17 @@ fn main() {
 
     let mut i = h.iter();
 
-    foreach (&k,&v) in i {
+    for (&k,&v) in i {
         x += k;
         y += v;
         break;
     }
 
-    foreach (&k,&v) in i {
+    for (&k,&v) in i {
         x += k;
         y += v;
     }
 
     assert_eq!(x, 6);
     assert_eq!(y, 60);
-}
\ No newline at end of file
+}