]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/overload-index-operator.rs
Replace all ~"" with "".to_owned()
[rust.git] / src / test / run-pass / overload-index-operator.rs
index 706168844f5121a5736cadcafa3eaee68e6d7d68..b72c4f92ea3e796cf73641c725b712759a800f77 100644 (file)
@@ -14,8 +14,7 @@
 use std::ops::Index;
 
 struct AssociationList<K,V> {
-    pairs: ~[AssociationPair<K,V>]
-}
+    pairs: Vec<AssociationPair<K,V>> }
 
 #[deriving(Clone)]
 struct AssociationPair<K,V> {
@@ -31,20 +30,20 @@ fn push(&mut self, key: K, value: V) {
 
 impl<K:Eq,V:Clone> Index<K,V> for AssociationList<K,V> {
     fn index(&self, index: &K) -> V {
-        foreach pair in self.pairs.iter() {
+        for pair in self.pairs.iter() {
             if pair.key == *index {
                 return pair.value.clone();
             }
         }
-        fail!("No value found for key: %?", index);
+        fail!("No value found for key: {:?}", index);
     }
 }
 
 pub fn main() {
-    let foo = ~"foo";
-    let bar = ~"bar";
+    let foo = "foo".to_owned();
+    let bar = "bar".to_owned();
 
-    let mut list = AssociationList {pairs: ~[]};
+    let mut list = AssociationList {pairs: Vec::new()};
     list.push(foo.clone(), 22);
     list.push(bar.clone(), 44);