summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-01-10 20:09:16 -0800
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-01-10 20:10:10 -0800
commit3e7da96fd22faf8587c1717e03a988dce6893bdb (patch)
tree7ce24907beb50d51849fa1eb08a5e46ec6afd72c /src/libstd
parent30c308b952def6b0967c88556e153f1507fb3529 (diff)
downloadrust-3e7da96fd22faf8587c1717e03a988dce6893bdb.tar.gz
rust-3e7da96fd22faf8587c1717e03a988dce6893bdb.zip
std: Fix pattern match on reference, address an XXX
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/json.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index f29e2b5e2ca..9a1d7b4a81e 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -926,22 +926,20 @@ pub impl Decoder: serialize::Decoder {
 
 impl Json : Eq {
     pure fn eq(&self, other: &Json) -> bool {
-        // XXX: This is ugly because matching on references is broken, and
-        // we can't match on dereferenced tuples without a copy.
-        match (*self) {
-            Number(f0) =>
-                match *other { Number(f1) => f0 == f1, _ => false },
-            String(ref s0) =>
-                match *other { String(ref s1) => s0 == s1, _ => false },
-            Boolean(b0) =>
-                match *other { Boolean(b1) => b0 == b1, _ => false },
-            Null =>
-                match *other { Null => true, _ => false },
-            List(ref v0) =>
-                match *other { List(ref v1) => v0 == v1, _ => false },
-            Object(ref d0) => {
-                match *other {
-                    Object(ref d1) => {
+        match (self) {
+            &Number(f0) =>
+                match other { &Number(f1) => f0 == f1, _ => false },
+            &String(ref s0) =>
+                match other { &String(ref s1) => s0 == s1, _ => false },
+            &Boolean(b0) =>
+                match other { &Boolean(b1) => b0 == b1, _ => false },
+            &Null =>
+                match other { &Null => true, _ => false },
+            &List(ref v0) =>
+                match other { &List(ref v1) => v0 == v1, _ => false },
+            &Object(ref d0) => {
+                match other {
+                    &Object(ref d1) => {
                         if d0.len() == d1.len() {
                             let mut equal = true;
                             for d0.each |k, v0| {
@@ -960,7 +958,7 @@ impl Json : Eq {
             }
         }
     }
-    pure fn ne(&self, other: &Json) -> bool { !(*self).eq(other) }
+    pure fn ne(&self, other: &Json) -> bool { !self.eq(other) }
 }
 
 /// Test if two json values are less than one another
@@ -1007,7 +1005,7 @@ impl Json : Ord {
                             let mut d0_flat = ~[];
                             let mut d1_flat = ~[];
 
-                            // XXX: this is horribly inefficient...
+                            // FIXME #4430: this is horribly inefficient...
                             for d0.each |k, v| {
                                  d0_flat.push((@copy *k, @copy *v));
                             }