use crate::Arena;
pub trait AnyRef<T: ?Sized> {
fn as_ptr(&self) -> *const T;
fn owned_by(&self, arena: &Arena<T>) -> bool;
#[inline]
fn is<O: AnyRef<T>>(&self, other: &O) -> bool {
core::ptr::eq(self.as_ptr(), other.as_ptr())
}
#[inline]
fn is_not<O: AnyRef<T>>(&self, other: &O) -> bool {
!self.is(other)
}
}
macro_rules! inherent_ref_methods {
(<$T:ident>) => {
#[inline]
pub fn is<O: crate::AnyRef<$T>>(&self, other: &O) -> bool {
crate::AnyRef::is(self, other)
}
#[inline]
pub fn is_not<O: crate::AnyRef<$T>>(&self, other: &O) -> bool {
crate::AnyRef::is_not(self, other)
}
};
}
pub(crate) use inherent_ref_methods;