@@ -107,56 +107,55 @@ impl Expression {
107
107
if !matches ! ( root. kind, ValueKind :: Table ( _) ) {
108
108
* root = Map :: < String , Value > :: new ( ) . into ( ) ;
109
109
}
110
-
111
- if let ValueKind :: Table ( ref mut map) = root. kind {
112
- map. entry ( key. clone ( ) )
113
- . or_insert_with ( || Value :: new ( None , ValueKind :: Nil ) )
114
- } else {
110
+ let ValueKind :: Table ( ref mut map) = root. kind else {
115
111
unreachable ! ( )
116
- }
112
+ } ;
113
+
114
+ map. entry ( key. clone ( ) )
115
+ . or_insert_with ( || Value :: new ( None , ValueKind :: Nil ) )
117
116
}
118
117
119
118
Self :: Child ( ref expr, ref key) => {
120
119
let child = expr. get_mut_forcibly ( root) ;
120
+
121
121
if !matches ! ( child. kind, ValueKind :: Table ( _) ) {
122
122
* child = Map :: < String , Value > :: new ( ) . into ( ) ;
123
123
}
124
-
125
- if let ValueKind :: Table ( ref mut map) = child. kind {
126
- map. entry ( key. clone ( ) )
127
- . or_insert_with ( || Value :: new ( None , ValueKind :: Nil ) )
128
- } else {
124
+ let ValueKind :: Table ( ref mut map) = child. kind else {
129
125
unreachable ! ( )
130
- }
126
+ } ;
127
+
128
+ map. entry ( key. clone ( ) )
129
+ . or_insert_with ( || Value :: new ( None , ValueKind :: Nil ) )
131
130
}
132
131
133
132
Self :: Subscript ( ref expr, index) => {
134
133
let child = expr. get_mut_forcibly ( root) ;
134
+
135
135
if !matches ! ( child. kind, ValueKind :: Array ( _) ) {
136
136
* child = Vec :: < Value > :: new ( ) . into ( ) ;
137
137
}
138
+ let ValueKind :: Array ( ref mut array) = child. kind else {
139
+ unreachable ! ( )
140
+ } ;
138
141
139
- if let ValueKind :: Array ( ref mut array) = child. kind {
140
- let uindex = match abs_index ( index, array. len ( ) ) {
141
- Ok ( uindex) => {
142
- if uindex >= array. len ( ) {
143
- array. resize ( uindex + 1 , Value :: new ( None , ValueKind :: Nil ) ) ;
144
- }
145
- uindex
142
+ let uindex = match abs_index ( index, array. len ( ) ) {
143
+ Ok ( uindex) => {
144
+ if uindex >= array. len ( ) {
145
+ array. resize ( uindex + 1 , Value :: new ( None , ValueKind :: Nil ) ) ;
146
146
}
147
- Err ( insertion) => {
148
- array. splice (
149
- 0 ..0 ,
150
- ( 0 ..insertion) . map ( |_| Value :: new ( None , ValueKind :: Nil ) ) ,
151
- ) ;
152
- 0
153
- }
154
- } ;
147
+ uindex
148
+ }
149
+ Err ( insertion) => {
150
+ array. splice (
151
+ 0 ..0 ,
152
+ ( 0 ..insertion) . map ( |_| Value :: new ( None , ValueKind :: Nil ) ) ,
153
+ ) ;
154
+ 0
155
+ }
156
+ } ;
155
157
156
- & mut array[ uindex]
157
- } else {
158
- unreachable ! ( )
159
- }
158
+ & mut array[ uindex]
160
159
}
161
160
}
162
161
}
0 commit comments