@@ -35,8 +35,8 @@ use pretty_assertions::assert_eq;
35
35
use rstest:: { fixture, rstest} ;
36
36
use rustic_core:: {
37
37
repofile:: SnapshotFile , BackupOptions , CheckOptions , ConfigOptions , FindMatches , FindNode ,
38
- KeyOptions , LimitOption , LsOptions , NoProgressBars , OpenStatus , PathList , Repository ,
39
- RepositoryBackends , RepositoryOptions , RusticResult ,
38
+ FullIndex , IndexedFull , IndexedStatus , KeyOptions , LimitOption , LsOptions , NoProgressBars ,
39
+ OpenStatus , PathList , Repository , RepositoryBackends , RepositoryOptions , RusticResult ,
40
40
} ;
41
41
use rustic_core:: {
42
42
repofile:: { Metadata , Node } ,
@@ -464,3 +464,32 @@ fn test_prune(
464
464
465
465
Ok ( ( ) )
466
466
}
467
+
468
+ /// Verifies that users can create wrappers around repositories
469
+ /// without resorting to generics. The rationale is that such
470
+ /// types can be used to dynamically open, store, and cache repos.
471
+ ///
472
+ /// See issue #277 for more context.
473
+ #[ test]
474
+ fn test_wrapping_in_new_type ( ) -> Result < ( ) > {
475
+ struct Wrapper ( Repository < NoProgressBars , IndexedStatus < FullIndex , OpenStatus > > ) ;
476
+
477
+ impl Wrapper {
478
+ fn new ( ) -> Result < Self > {
479
+ Ok ( Self ( set_up_repo ( ) ?. to_indexed ( ) ?) )
480
+ }
481
+ }
482
+
483
+ /// Fake function that "does something" with a fully indexed repo
484
+ /// (without actually relying on any functionality for the test)
485
+ fn use_repo ( _: & impl IndexedFull ) { }
486
+
487
+ let mut collection: Vec < Wrapper > = Vec :: new ( ) ;
488
+
489
+ collection. push ( Wrapper :: new ( ) ?) ;
490
+ collection. push ( Wrapper :: new ( ) ?) ;
491
+
492
+ collection. iter ( ) . map ( |r| & r. 0 ) . for_each ( use_repo) ;
493
+
494
+ Ok ( ( ) )
495
+ }
0 commit comments