pub trait PtrMagic: Sized {
// Provided methods
fn into_raw(self) -> *mut Self { ... }
fn from_raw(ptr: *mut Self) -> Self { ... }
unsafe fn from_borrow<'a>(ptr: *mut Self) -> &'a mut Self { ... }
}Expand description
A shared trait for converting from/to a pointer. Specifically a (* mut Self)
Provided Methods§
Sourcefn into_raw(self) -> *mut Self
fn into_raw(self) -> *mut Self
Moves the object to the heap and returns a raw pointer. Caller owns this memory but don’t worry about freeing it. The library frees it somewhere.
Sourceunsafe fn from_borrow<'a>(ptr: *mut Self) -> &'a mut Self
unsafe fn from_borrow<'a>(ptr: *mut Self) -> &'a mut Self
Build from a Ptr but only get a reference, this means that the caller will still own the memory
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.