pub trait Pointer: Sized {
type Target;
// Required methods
fn as_ref(&self) -> &Self::Target;
unsafe fn from_raw(p: *const Self::Target) -> Self;
fn into_raw(self) -> *const Self::Target;
}Expand description
Abstract pointer trait to support various pointer types in collections.
This trait allows the collections to work with:
Box<T>: Owned, automatically dropped.Arc<T>: Shared ownership.Rc<T>: Single thread ownership.NonNull<T>: Raw non-null pointers (manual memory management).*const T: Raw pointers (recommend to useNonNull<T>instead)
Required Associated Types§
Required Methods§
fn as_ref(&self) -> &Self::Target
unsafe fn from_raw(p: *const Self::Target) -> Self
fn into_raw(self) -> *const Self::Target
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.