Skip to content

Commit dfc1c28

Browse files
authored
Merge branch 'main' into dep-update
2 parents bcd8933 + 1e7b4a8 commit dfc1c28

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

crates/core/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,7 @@ pub use crate::{
148148
repofile::snapshotfile::{
149149
PathList, SnapshotGroup, SnapshotGroupCriterion, SnapshotOptions, StringList,
150150
},
151-
repository::{IndexedFull, OpenStatus, Repository, RepositoryOptions},
151+
repository::{
152+
FullIndex, IndexedFull, IndexedStatus, OpenStatus, Repository, RepositoryOptions,
153+
},
152154
};

crates/core/tests/integration.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ use pretty_assertions::assert_eq;
3535
use rstest::{fixture, rstest};
3636
use rustic_core::{
3737
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,
4040
};
4141
use rustic_core::{
4242
repofile::{Metadata, Node},
@@ -464,3 +464,29 @@ fn test_prune(
464464

465465
Ok(())
466466
}
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 collection: Vec<Wrapper> = vec![Wrapper::new()?, Wrapper::new()?];
488+
489+
collection.iter().map(|r| &r.0).for_each(use_repo);
490+
491+
Ok(())
492+
}

0 commit comments

Comments
 (0)