Implement ptr_eq on the context types.

This commit is contained in:
Tom Alexander 2022-12-10 22:04:39 -05:00
parent 7ba863118f
commit 2a595e2b6c
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 17 additions and 0 deletions

View File

@ -64,4 +64,12 @@ impl<T: Debug> List<T> {
pub fn is_empty(&self) -> bool {
self.head.is_none()
}
pub fn ptr_eq(&self, other: &List<T>) -> bool {
match (self.head.as_ref(), other.head.as_ref()) {
(None, None) => true,
(None, Some(_)) | (Some(_), None) => false,
(Some(me), Some(them)) => Rc::ptr_eq(me, them),
}
}
}

View File

@ -18,6 +18,10 @@ impl<'r> ContextTree<'r> {
ContextTree { tree: List::new() }
}
pub fn ptr_eq<'x>(&self, other: &ContextTree<'x>) -> bool {
self.tree.ptr_eq(&other.tree)
}
pub fn with_additional_node(&self, data: ContextElement<'r>) -> ContextTree<'r> {
let new_list = self.tree.push_front(data);
ContextTree { tree: new_list }

View File

@ -62,6 +62,11 @@ where
match till_matcher(&current_context, i.clone()) {
Ok((remaining, finish)) => {
let mut ret = Vec::new();
while !current_context.ptr_eq(context) {
// todo
todo!()
}
// while current_context.tr
// TODO build a vec of the elements by popping off the newest elements of the context
return Ok((remaining, (ret, finish)));
}