#[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 Into<RawGcPtr> for GcPtr {
fn into(self) -> RawGcPtr {
self.0
}
}
impl Into<GcPtr> for RawGcPtr {
fn into(self) -> GcPtr {
GcPtr(self)
}
}
impl GcPtr {
pub(crate) fn as_ptr(self) -> RawGcPtr {
self.0
}
}