Skip to content

Commit 3e7da96

Browse files
committed
std: Fix pattern match on reference, address an XXX
1 parent 30c308b commit 3e7da96

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/libstd/json.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -926,22 +926,20 @@ pub impl Decoder: serialize::Decoder {
926926

927927
impl Json : Eq {
928928
pure fn eq(&self, other: &Json) -> bool {
929-
// XXX: This is ugly because matching on references is broken, and
930-
// we can't match on dereferenced tuples without a copy.
931-
match (*self) {
932-
Number(f0) =>
933-
match *other { Number(f1) => f0 == f1, _ => false },
934-
String(ref s0) =>
935-
match *other { String(ref s1) => s0 == s1, _ => false },
936-
Boolean(b0) =>
937-
match *other { Boolean(b1) => b0 == b1, _ => false },
938-
Null =>
939-
match *other { Null => true, _ => false },
940-
List(ref v0) =>
941-
match *other { List(ref v1) => v0 == v1, _ => false },
942-
Object(ref d0) => {
943-
match *other {
944-
Object(ref d1) => {
929+
match (self) {
930+
&Number(f0) =>
931+
match other { &Number(f1) => f0 == f1, _ => false },
932+
&String(ref s0) =>
933+
match other { &String(ref s1) => s0 == s1, _ => false },
934+
&Boolean(b0) =>
935+
match other { &Boolean(b1) => b0 == b1, _ => false },
936+
&Null =>
937+
match other { &Null => true, _ => false },
938+
&List(ref v0) =>
939+
match other { &List(ref v1) => v0 == v1, _ => false },
940+
&Object(ref d0) => {
941+
match other {
942+
&Object(ref d1) => {
945943
if d0.len() == d1.len() {
946944
let mut equal = true;
947945
for d0.each |k, v0| {
@@ -960,7 +958,7 @@ impl Json : Eq {
960958
}
961959
}
962960
}
963-
pure fn ne(&self, other: &Json) -> bool { !(*self).eq(other) }
961+
pure fn ne(&self, other: &Json) -> bool { !self.eq(other) }
964962
}
965963

966964
/// Test if two json values are less than one another
@@ -1007,7 +1005,7 @@ impl Json : Ord {
10071005
let mut d0_flat = ~[];
10081006
let mut d1_flat = ~[];
10091007

1010-
// XXX: this is horribly inefficient...
1008+
// FIXME #4430: this is horribly inefficient...
10111009
for d0.each |k, v| {
10121010
d0_flat.push((@copy *k, @copy *v));
10131011
}

0 commit comments

Comments
 (0)