Skip to content

Commit 8b27d0d

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 167887 b: refs/heads/master c: 6fc9257 h: refs/heads/master i: 167885: 797d4f8 167883: 20577b3 167879: 92ecfc1 167871: 7d6b6c4 v: v3
1 parent 91b4f42 commit 8b27d0d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4bfaa9397857b5b49657e3596e33800dbf35ade4
2+
refs/heads/master: 6fc92578fee125615b4357bdd3142a8f07b20b54
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c89417130f042c58adc60012e7cddc4ef70b70b9
55
refs/heads/try: 5204084bd2e46af7cc6e0147430e44dd0d657bbb

trunk/src/libserialize/json.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,25 @@ impl Json {
11231123
}
11241124
}
11251125

1126+
// NOTE(stage0): remove impl after a snapshot
1127+
#[cfg(stage0)]
11261128
impl<'a> ops::Index<&'a str, Json> for Json {
11271129
fn index(&self, idx: & &str) -> &Json {
11281130
self.find(*idx).unwrap()
11291131
}
11301132
}
11311133

1134+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1135+
impl<'a> ops::Index<&'a str> for Json {
1136+
type Output = Json;
1137+
1138+
fn index(&self, idx: & &str) -> &Json {
1139+
self.find(*idx).unwrap()
1140+
}
1141+
}
1142+
1143+
// NOTE(stage0): remove impl after a snapshot
1144+
#[cfg(stage0)]
11321145
impl ops::Index<uint, Json> for Json {
11331146
fn index<'a>(&'a self, idx: &uint) -> &'a Json {
11341147
match self {
@@ -1138,6 +1151,18 @@ impl ops::Index<uint, Json> for Json {
11381151
}
11391152
}
11401153

1154+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1155+
impl ops::Index<uint> for Json {
1156+
type Output = Json;
1157+
1158+
fn index<'a>(&'a self, idx: &uint) -> &'a Json {
1159+
match self {
1160+
&Json::Array(ref v) => v.index(idx),
1161+
_ => panic!("can only index Json with uint if it is an array")
1162+
}
1163+
}
1164+
}
1165+
11411166
/// The output of the streaming parser.
11421167
#[deriving(PartialEq, Clone, Show)]
11431168
pub enum JsonEvent {

0 commit comments

Comments
 (0)