#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
pub struct GcPtr(RawGcPtr);
unsafe impl Send for GcPtr {}
unsafe impl Sync for GcPtr {}
pub type RawGcPtr = *const *mut std::ffi::c_void;
pub trait HasIndirectionPtr {
unsafe fn deref<T: Sized>(&self) -> *const T;
unsafe fn deref_mut<T: Sized>(&mut self) -> *mut T {
self.deref::<T>() as *mut _
}
}
impl HasIndirectionPtr for GcPtr {
unsafe fn deref<T: Sized>(&self) -> *const T {
(*self.0).cast()
}
}
impl From<GcPtr> for RawGcPtr {
fn from(ptr: GcPtr) -> Self {
ptr.0
}
}
impl From<RawGcPtr> for GcPtr {
fn from(ptr: RawGcPtr) -> Self {
GcPtr(ptr)
}
}
impl GcPtr {
pub(crate) fn as_ptr(self) -> RawGcPtr {
self.0
}
}