1
1
use std:: {
2
- cmp:: Reverse , convert:: Infallible , env, fs, iter, mem, path:: PathBuf ,
2
+ cmp:: Reverse , collections:: HashSet , convert:: Infallible , env, fs, iter,
3
+ mem, path:: PathBuf ,
3
4
} ;
4
5
5
6
use camino:: { Utf8Path , Utf8PathBuf } ;
@@ -323,21 +324,23 @@ fn cache_snapshots_entries() {
323
324
assert_eq ! ( s0. original_id, s1. original_id) ;
324
325
assert_eq ! ( s0. program_version, s1. program_version) ;
325
326
326
- let mut s0_paths: Vec < String > = s0. paths . to_vec ( ) ;
327
+ let mut s0_paths: Vec < String > = s0. paths . iter ( ) . cloned ( ) . collect ( ) ;
327
328
s0_paths. sort ( ) ;
328
- let mut s1_paths: Vec < String > = s1. paths . to_vec ( ) ;
329
+ let mut s1_paths: Vec < String > = s1. paths . iter ( ) . cloned ( ) . collect ( ) ;
329
330
s1_paths. sort ( ) ;
330
331
assert_eq ! ( s0_paths, s1_paths) ;
331
332
332
- let mut s0_excludes: Vec < String > = s0. excludes . to_vec ( ) ;
333
+ let mut s0_excludes: Vec < String > =
334
+ s0. excludes . iter ( ) . cloned ( ) . collect ( ) ;
333
335
s0_excludes. sort ( ) ;
334
- let mut s1_excludes: Vec < String > = s1. excludes . to_vec ( ) ;
336
+ let mut s1_excludes: Vec < String > =
337
+ s1. excludes . iter ( ) . cloned ( ) . collect ( ) ;
335
338
s1_excludes. sort ( ) ;
336
339
assert_eq ! ( s0_excludes, s1_excludes) ;
337
340
338
- let mut s0_tags: Vec < String > = s0. tags . to_vec ( ) ;
341
+ let mut s0_tags: Vec < String > = s0. tags . iter ( ) . cloned ( ) . collect ( ) ;
339
342
s0_tags. sort ( ) ;
340
- let mut s1_tags: Vec < String > = s1. tags . to_vec ( ) ;
343
+ let mut s1_tags: Vec < String > = s1. tags . iter ( ) . cloned ( ) . collect ( ) ;
341
344
s1_tags. sort ( ) ;
342
345
assert_eq ! ( s0_tags, s1_tags) ;
343
346
}
@@ -355,7 +358,9 @@ fn cache_snapshots_entries() {
355
358
"/home/user" . to_string( ) ,
356
359
"/etc" . to_string( ) ,
357
360
"/var" . to_string( ) ,
358
- ] ,
361
+ ]
362
+ . into_iter ( )
363
+ . collect ( ) ,
359
364
hostname : Some ( "foo.com" . to_string ( ) ) ,
360
365
username : Some ( "user" . to_string ( ) ) ,
361
366
uid : Some ( 123 ) ,
@@ -364,8 +369,12 @@ fn cache_snapshots_entries() {
364
369
".cache" . to_string( ) ,
365
370
"Cache" . to_string( ) ,
366
371
"/home/user/Downloads" . to_string( ) ,
367
- ] ,
368
- tags : vec ! [ "foo_machine" . to_string( ) , "rewrite" . to_string( ) ] ,
372
+ ]
373
+ . into_iter ( )
374
+ . collect ( ) ,
375
+ tags : vec ! [ "foo_machine" . to_string( ) , "rewrite" . to_string( ) ]
376
+ . into_iter ( )
377
+ . collect ( ) ,
369
378
original_id : Some ( "fefwfwew" . to_string ( ) ) ,
370
379
program_version : Some ( "restic 0.16.0" . to_string ( ) ) ,
371
380
} ;
@@ -375,7 +384,7 @@ fn cache_snapshots_entries() {
375
384
time : mk_datetime ( 2025 , 5 , 12 , 17 , 00 , 00 ) ,
376
385
parent : Some ( "wat" . to_string ( ) ) ,
377
386
tree : "anothertree" . to_string ( ) ,
378
- paths : vec ! [ "/home/user" . to_string( ) ] ,
387
+ paths : vec ! [ "/home/user" . to_string( ) ] . into_iter ( ) . collect ( ) ,
379
388
hostname : Some ( "foo.com" . to_string ( ) ) ,
380
389
username : Some ( "user" . to_string ( ) ) ,
381
390
uid : Some ( 123 ) ,
@@ -384,8 +393,12 @@ fn cache_snapshots_entries() {
384
393
".cache" . to_string( ) ,
385
394
"Cache" . to_string( ) ,
386
395
"/home/user/Downloads" . to_string( ) ,
387
- ] ,
388
- tags : vec ! [ "foo_machine" . to_string( ) , "rewrite" . to_string( ) ] ,
396
+ ]
397
+ . into_iter ( )
398
+ . collect ( ) ,
399
+ tags : vec ! [ "foo_machine" . to_string( ) , "rewrite" . to_string( ) ]
400
+ . into_iter ( )
401
+ . collect ( ) ,
389
402
original_id : Some ( "fefwfwew" . to_string ( ) ) ,
390
403
program_version : Some ( "restic 0.16.0" . to_string ( ) ) ,
391
404
} ;
@@ -395,13 +408,13 @@ fn cache_snapshots_entries() {
395
408
time : mk_datetime ( 2023 , 5 , 12 , 17 , 00 , 00 ) ,
396
409
parent : None ,
397
410
tree : "fwefwfwwefwefwe" . to_string ( ) ,
398
- paths : vec ! [ ] ,
411
+ paths : HashSet :: new ( ) ,
399
412
hostname : None ,
400
413
username : None ,
401
414
uid : None ,
402
415
gid : None ,
403
- excludes : vec ! [ ] ,
404
- tags : vec ! [ ] ,
416
+ excludes : HashSet :: new ( ) ,
417
+ tags : HashSet :: new ( ) ,
405
418
original_id : None ,
406
419
program_version : None ,
407
420
} ;
@@ -460,13 +473,13 @@ fn lots_of_snapshots() {
460
473
time : timestamp_to_datetime ( i as i64 ) . unwrap ( ) ,
461
474
parent : None ,
462
475
tree : i. to_string ( ) ,
463
- paths : vec ! [ ] ,
476
+ paths : HashSet :: new ( ) ,
464
477
hostname : None ,
465
478
username : None ,
466
479
uid : None ,
467
480
gid : None ,
468
- excludes : vec ! [ ] ,
469
- tags : vec ! [ ] ,
481
+ excludes : HashSet :: new ( ) ,
482
+ tags : HashSet :: new ( ) ,
470
483
original_id : None ,
471
484
program_version : None ,
472
485
} ;
0 commit comments