[][src]Trait smart_pointer::SmartPointer

pub trait SmartPointer<T: ?Sized>: Sized + AsRef<T> + Borrow<T> + Deref<Target = T> + Pointer {
    fn new(t: T) -> Self
    where
        T: Sized
;
fn try_unwrap(this: Self) -> Result<T, Self>
    where
        T: Sized
; fn ptr_eq(a: &Self, b: &Self) -> bool { ... } }

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

fn new(t: T) -> Self where
    T: Sized

Construct a new smart pointer, containing the given value.

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.

Loading content...

Provided methods

fn ptr_eq(a: &Self, b: &Self) -> bool

Returns whether two smart pointers point to the same location in memory.

The default implementation borrows the inner values and compares their locations.

Loading content...

Implementors

Loading content...