pub unsafe trait Pointer<T> where
Self: Sized + Deref<Target = T>, {
fn into_raw(self) -> *mut T;
unsafe fn from_raw(ptr: *mut T) -> Self;
}
Expand description
A type that can be turned into, and converted from, a raw pointer whose referent is T
.
Safety
- the
*mut T
returned frominto_raw
must be valid as a&mut T
when it is returned. - the
*mut T
returned frominto_raw
must remain valid as a&T
until it is passed tofrom_raw
. from_raw
must not return a particular*mut T
again until the providedself
is dropped after an eventual call tofrom_raw
.
Required methods
Reconstruct this pointer type from the given ptr
.
Safety (for callers)
ptr
must be a pointer returned bySelf::into_raw
ptr
must be valid to dereference to aT
ptr
must not have been passed tofrom_raw
since it was returned frominto_raw
ptr
must not be aliased