@@ -152,10 +152,13 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
152
152
key : BoundedVec <u8 , KeyBytes >,
153
153
) -> Option <BoundedVec <u8 , StringBytes >> {
154
154
let (exists , entry ) = self .get_json_entry_var (key );
155
- assert (
156
- (entry .entry_type - STRING_TOKEN as Field ) * exists as Field == 0 ,
157
- "get_string: entry exists but is not a string!" ,
158
- );
155
+ if exists {
156
+ assert_eq (
157
+ entry .entry_type ,
158
+ STRING_TOKEN as Field ,
159
+ "get_string: entry exists but is not a string!" ,
160
+ );
161
+ }
159
162
let mut parsed_string : [u8 ; StringBytes ] = self .extract_string_entry (entry );
160
163
let parsed_string : BoundedVec <u8 , StringBytes > = process_escape_sequences (
161
164
BoundedVec ::from_parts_unchecked (parsed_string , entry .json_length as u32 ),
@@ -176,8 +179,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
176
179
key : BoundedVec <u8 , KeyBytes >,
177
180
) -> BoundedVec <u8 , StringBytes > {
178
181
let entry = self .get_json_entry_unchecked_var (key );
179
- assert (
180
- entry .entry_type == STRING_TOKEN as Field ,
182
+ assert_eq (
183
+ entry .entry_type ,
184
+ STRING_TOKEN as Field ,
181
185
"get_string_unchecked: entry exists but is not a string!" ,
182
186
);
183
187
let parsed_string = BoundedVec ::from_parts_unchecked (
@@ -195,8 +199,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
195
199
self ,
196
200
array_index : Field ,
197
201
) -> Option <BoundedVec <u8 , StringBytes >> {
198
- assert (
199
- self .layer_type_of_root == ARRAY_LAYER ,
202
+ assert_eq (
203
+ self .layer_type_of_root ,
204
+ ARRAY_LAYER ,
200
205
"can only acceess array elements from array" ,
201
206
);
202
207
@@ -235,9 +240,10 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
235
240
self ,
236
241
array_index : Field ,
237
242
) -> BoundedVec <u8 , StringBytes > {
238
- assert (
239
- self .layer_type_of_root == ARRAY_LAYER ,
240
- "can only acceess array elements from array" ,
243
+ assert_eq (
244
+ self .layer_type_of_root ,
245
+ ARRAY_LAYER ,
246
+ "can only access array elements from array" ,
241
247
);
242
248
243
249
let parent_entry : JSONEntry =
@@ -249,8 +255,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
249
255
250
256
let entry : JSONEntry = self .json_entries_packed [cast_num_to_u32 (entry_index )].into ();
251
257
252
- assert (
253
- entry .entry_type == STRING_TOKEN as Field ,
258
+ assert_eq (
259
+ entry .entry_type ,
260
+ STRING_TOKEN as Field ,
254
261
"get_string_from_array_unchecked: entry exists but is not a string!" ,
255
262
);
256
263
@@ -375,8 +382,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
375
382
self ,
376
383
array_index : Field ,
377
384
) -> Option <JSONValue <StringBytes >> {
378
- assert (
379
- self .layer_type_of_root == ARRAY_LAYER ,
385
+ assert_eq (
386
+ self .layer_type_of_root ,
387
+ ARRAY_LAYER ,
380
388
"can only acceess array elements from array" ,
381
389
);
382
390
@@ -420,8 +428,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
420
428
self ,
421
429
array_index : Field ,
422
430
) -> JSONValue <StringBytes > {
423
- assert (
424
- self .layer_type_of_root == ARRAY_LAYER ,
431
+ assert_eq (
432
+ self .layer_type_of_root ,
433
+ ARRAY_LAYER ,
425
434
"can only acceess array elements from array" ,
426
435
);
427
436
@@ -434,8 +443,9 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
434
443
435
444
let entry : JSONEntry = self .json_entries_packed [cast_num_to_u32 (entry_index )].into ();
436
445
437
- assert (
438
- entry .entry_type == STRING_TOKEN as Field ,
446
+ assert_eq (
447
+ entry .entry_type ,
448
+ STRING_TOKEN as Field ,
439
449
"get_string_from_array_unchecked: entry exists but is not a string!" ,
440
450
);
441
451
0 commit comments