@@ -272,34 +272,7 @@ fn normalize_value_to_unordered_redactions(
272
272
* act = normalize_str_to_unordered_redactions ( act, exp, substitutions) ;
273
273
}
274
274
( Array ( act) , Array ( exp) ) => {
275
- let mut actual_values = std:: mem:: take ( act) ;
276
- let mut expected_values = exp. clone ( ) ;
277
- let mut elided = false ;
278
- expected_values. retain ( |expected_value| {
279
- let mut matched = false ;
280
- if expected_value == VALUE_WILDCARD {
281
- matched = true ;
282
- elided = true ;
283
- } else {
284
- actual_values. retain ( |actual_value| {
285
- if !matched && actual_value == expected_value {
286
- matched = true ;
287
- false
288
- } else {
289
- true
290
- }
291
- } ) ;
292
- }
293
- if matched {
294
- act. push ( expected_value. clone ( ) ) ;
295
- }
296
- !matched
297
- } ) ;
298
- if !elided {
299
- for actual_value in actual_values {
300
- act. push ( actual_value) ;
301
- }
302
- }
275
+ * act = normalize_array_to_unordered_redactions ( act, exp) ;
303
276
}
304
277
( Object ( act) , Object ( exp) ) => {
305
278
let has_key_wildcard =
@@ -324,6 +297,44 @@ fn normalize_value_to_unordered_redactions(
324
297
}
325
298
}
326
299
300
+ #[ cfg( feature = "structured-data" ) ]
301
+ fn normalize_array_to_unordered_redactions (
302
+ actual : & [ serde_json:: Value ] ,
303
+ expected : & [ serde_json:: Value ] ,
304
+ ) -> Vec < serde_json:: Value > {
305
+ let mut normalized: Vec < serde_json:: Value > = Vec :: new ( ) ;
306
+ let mut actual_values = actual. to_owned ( ) ;
307
+ let mut expected_values = expected. to_owned ( ) ;
308
+ let mut elided = false ;
309
+ expected_values. retain ( |expected_value| {
310
+ let mut matched = false ;
311
+ if expected_value == VALUE_WILDCARD {
312
+ matched = true ;
313
+ elided = true ;
314
+ } else {
315
+ actual_values. retain ( |actual_value| {
316
+ if !matched && actual_value == expected_value {
317
+ matched = true ;
318
+ false
319
+ } else {
320
+ true
321
+ }
322
+ } ) ;
323
+ }
324
+ if matched {
325
+ normalized. push ( expected_value. clone ( ) ) ;
326
+ }
327
+ !matched
328
+ } ) ;
329
+ if !elided {
330
+ for actual_value in actual_values {
331
+ normalized. push ( actual_value) ;
332
+ }
333
+ }
334
+
335
+ normalized
336
+ }
337
+
327
338
fn normalize_str_to_unordered_redactions (
328
339
actual : & str ,
329
340
expected : & str ,
0 commit comments