pub trait PtrExt { unsafe fn deref<'a>(self) -> &'a T; } pub trait MutPtrExt { unsafe fn deref_mut<'a>(self) -> &'a mut T; } impl PtrExt for *const T { #[inline(always)] unsafe fn deref<'a>(self) -> &'a T { unsafe { &*self } } } impl PtrExt for *mut T { #[inline(always)] unsafe fn deref<'a>(self) -> &'a T { unsafe { &*self } } } impl MutPtrExt for *mut T { #[inline(always)] unsafe fn deref_mut<'a>(self) -> &'a mut T { unsafe { &mut *self } } }