pub trait SmartPointer<T: ?Sized>:
Sized
+ AsRef<T>
+ Borrow<T>
+ Deref<Target = T>
+ Pointer {
// Required methods
fn new(t: T) -> Self
where T: Sized;
fn try_unwrap(this: Self) -> Result<T, Self>
where T: Sized;
// Provided method
fn ptr_eq(a: &Self, b: &Self) -> bool { ... }
}Expand description
The minimum amount of functionality common to all smart pointer types pointing to a
value of type T. This trait only grants immutable access to the stored value, see
SmartPointerMut for mutable access and TryIntoMut for fallible conversion into a mutable
variant.
Note that most of the actual pointer functionality comes from the prerequisite traits.
Also note that this trait omits some functionality because it can only be expressed with
higher-kinded types, such as working with uninitialized memory, conversions to slices,
downcasting of Any values.
Required Methods§
Sourcefn try_unwrap(this: Self) -> Result<T, Self>where
T: Sized,
fn try_unwrap(this: Self) -> Result<T, Self>where
T: Sized,
Try to obtain ownership of the wrapped value.
This fails if there are other smart pointers wrapping the exact same value.
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.