Struct SharedPtr

struct SharedPtr<T> { ... }
where
    T: SharedPtrTarget

Binding to C++ std::shared_ptr<T>.

Implementations

impl<T> SharedPtr<T>

fn null() -> Self

Makes a new SharedPtr wrapping a null pointer.

Matches the behavior of default-constructing a std::shared_ptr.

fn new(value: T) -> Self
where
    T: ExternType<Kind = Trivial>

Allocates memory on the heap and makes a SharedPtr owner for it.

fn is_null(self: &Self) -> bool

Checks whether the SharedPtr does not own an object.

This is the opposite of std::shared_ptr<T>::operator bool.

fn as_ref(self: &Self) -> Option<&T>

Returns a reference to the object owned by this SharedPtr if any, otherwise None.

fn downgrade(self: &SharedPtr<T>) -> WeakPtr<T>
where
    T: WeakPtrTarget

Constructs new WeakPtr as a non-owning reference to the object managed by self. If self manages no object, the WeakPtr manages no object too.

Matches the behavior of std::weak_ptr<T>::weak_ptr(const std::shared_ptr<T> &).

impl<P, T> Receiver for SharedPtr<T>

impl<T> Any for SharedPtr<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SharedPtr<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SharedPtr<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Clone for SharedPtr<T>

fn clone(self: &Self) -> Self

impl<T> CloneToUninit for SharedPtr<T>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> Debug for SharedPtr<T>

fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result

impl<T> Deref for SharedPtr<T>

fn deref(self: &Self) -> &<Self as >::Target

impl<T> Display for SharedPtr<T>

fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result

impl<T> Drop for SharedPtr<T>

fn drop(self: &mut Self)

impl<T> Freeze for SharedPtr<T>

impl<T> From for SharedPtr<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for SharedPtr<T>

impl<T> Send for SharedPtr<T>

impl<T> Sync for SharedPtr<T>

impl<T> ToOwned for SharedPtr<T>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for SharedPtr<T>

fn to_string(self: &Self) -> String

impl<T> Unpin for SharedPtr<T>

impl<T> UnsafeUnpin for SharedPtr<T>

impl<T> UnwindSafe for SharedPtr<T>

impl<T, U> Into for SharedPtr<T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for SharedPtr<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for SharedPtr<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>