Switch to Rc to fix the multiple references issue.

This commit is contained in:
Tom Alexander 2022-10-30 04:57:06 -04:00
parent ce4b4a27f9
commit ec2d09b72a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ pub struct TestContext<T> {
head: ContextReference<T>,
}
type ContextReference<T> = Option<Box<ContextLayer<T>>>;
type ContextReference<T> = Option<Rc<ContextLayer<T>>>;
struct ContextLayer<T> {
data: T,
@ -32,11 +32,11 @@ impl TestContext<ContextData> {
new_matcher: MatcherRef,
) -> TestContext<ContextData> {
TestContext {
head: Some(Box::new(ContextLayer {
head: Some(Rc::new(ContextLayer {
data: ContextData {
fail_matcher: ChainBehavior::AndParent(Some(new_matcher)),
},
parent: self.head, // TODO FIX THIS
parent: self.head.clone(),
})),
}
}