pub trait IsPtr {
type T: ?Sized;
// Required methods
fn into_raw_ptr(this: Self) -> NonNull<Self::T>;
unsafe fn from_raw_ptr(ptr: NonNull<Self::T>) -> Self;
// Provided method
fn on_killed(_this: &Self) { ... }
}Expand description
Implemented for any owning pointer which can be dereferenced as T.
§Safety
When accepting an unknown impl IsPtr, be aware of the various guarantees
expected by all implementors. In particular, it may not be safe to mutate
the pointer since Pin<T>: IsPtr.
Required Associated Types§
Required Methods§
Sourcefn into_raw_ptr(this: Self) -> NonNull<Self::T>
fn into_raw_ptr(this: Self) -> NonNull<Self::T>
Converts to the raw pointer.
Sourceunsafe fn from_raw_ptr(ptr: NonNull<Self::T>) -> Self
unsafe fn from_raw_ptr(ptr: NonNull<Self::T>) -> Self
Converts from the raw pointer. This is used mainly to call drop.
§Safety
The given pointer must have been returned by Self::into_raw_ptr.
Provided Methods§
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.