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
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),
}
}
}