autocommit 2022-01-03 18:56:52 CET
This commit is contained in:
parent
fc887b339e
commit
30376c595c
39 changed files with 3157 additions and 309 deletions
25
src/utils/ptr_ext.rs
Normal file
25
src/utils/ptr_ext.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
pub trait PtrExt<T> {
|
||||
unsafe fn deref<'a>(self) -> &'a T;
|
||||
}
|
||||
|
||||
pub trait MutPtrExt<T> {
|
||||
unsafe fn deref_mut<'a>(self) -> &'a mut T;
|
||||
}
|
||||
|
||||
impl<T> PtrExt<T> for *const T {
|
||||
unsafe fn deref<'a>(self) -> &'a T {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PtrExt<T> for *mut T {
|
||||
unsafe fn deref<'a>(self) -> &'a T {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> MutPtrExt<T> for *mut T {
|
||||
unsafe fn deref_mut<'a>(self) -> &'a mut T {
|
||||
&mut *self
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue