]> Repositorios git - scryer-prolog.git/commitdiff
imitate Rc-style equality for TypedArenaPtr (#1190)
authorMark Thom <[email protected]>
Tue, 11 Jan 2022 01:25:30 +0000 (18:25 -0700)
committerMark Thom <[email protected]>
Tue, 11 Jan 2022 01:25:30 +0000 (18:25 -0700)
src/arena.rs

index d0244fae9324eff837cd6dfa1426685956e6d052..0dde07510d7b16dab3d64937ed01aa8a018a58bf 100644 (file)
@@ -72,9 +72,17 @@ impl ArenaHeader {
     }
 }
 
-#[derive(Debug, PartialEq, PartialOrd, Eq, Ord)]
+#[derive(Debug, PartialOrd, Ord)]
 pub struct TypedArenaPtr<T: ?Sized>(ptr::NonNull<T>);
 
+impl<T: ?Sized + PartialEq> PartialEq for TypedArenaPtr<T> {
+    fn eq(&self, other: &TypedArenaPtr<T>) -> bool {
+        self.0 == other.0 || &**self == &**other
+    }
+}
+
+impl<T: ?Sized + PartialEq> Eq for TypedArenaPtr<T> {}
+
 impl<T: ?Sized + Hash> Hash for TypedArenaPtr<T> {
     #[inline(always)]
     fn hash<H: Hasher>(&self, hasher: &mut H) {