File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1123,12 +1123,25 @@ impl Json {
1123
1123
}
1124
1124
}
1125
1125
1126
+ // NOTE(stage0): remove impl after a snapshot
1127
+ #[ cfg( stage0) ]
1126
1128
impl < ' a > ops:: Index < & ' a str , Json > for Json {
1127
1129
fn index ( & self , idx : & & str ) -> & Json {
1128
1130
self . find ( * idx) . unwrap ( )
1129
1131
}
1130
1132
}
1131
1133
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) ]
1132
1145
impl ops:: Index < uint , Json > for Json {
1133
1146
fn index < ' a > ( & ' a self , idx : & uint ) -> & ' a Json {
1134
1147
match self {
@@ -1138,6 +1151,18 @@ impl ops::Index<uint, Json> for Json {
1138
1151
}
1139
1152
}
1140
1153
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
+
1141
1166
/// The output of the streaming parser.
1142
1167
#[ deriving( PartialEq , Clone , Show ) ]
1143
1168
pub enum JsonEvent {
You can’t perform that action at this time.
0 commit comments