]> git.lizzy.rs Git - rust.git/blobdiff - src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
make `IndexMut` a super trait over `Index`
[rust.git] / src / test / compile-fail / borrowck-overloaded-index-autoderef.rs
index 9193a28511e70e069a540969b9048b168d7d9875..99f396ef8143213af415dbca2a649d0b4e1cd167 100644 (file)
@@ -22,7 +22,7 @@ impl Index<String> for Foo {
     type Output = isize;
 
     fn index<'a>(&'a self, z: &String) -> &'a isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &self.x
         } else {
             &self.y
@@ -31,10 +31,8 @@ fn index<'a>(&'a self, z: &String) -> &'a isize {
 }
 
 impl IndexMut<String> for Foo {
-    type Output = isize;
-
     fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &mut self.x
         } else {
             &mut self.y