Struct WeakPtr

#[repr(C)]
pub struct WeakPtr<T>
where
    T: WeakPtrTarget, { /* private fields */ }

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

The typical way to construct a WeakPtr from Rust is by downgrading from a SharedPtr.

Implementations

impl<T> WeakPtr<T> where T: WeakPtrTarget,

fn null() -> Self

Makes a new WeakPtr wrapping a null pointer.

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

fn upgrade(&self) -> SharedPtr<T>
where
    T: SharedPtrTarget,

Upgrades a non-owning reference into an owning reference if possible, otherwise to a null reference.

Matches the behavior of std::weak_ptr<T>::lock.

Trait Implementations

impl<T> Clone for WeakPtr<T> where T: WeakPtrTarget,

fn clone(&self) -> Self

impl<T> Debug for WeakPtr<T> where T: Debug + WeakPtrTarget + SharedPtrTarget,

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

impl<T> Drop for WeakPtr<T> where T: WeakPtrTarget,

fn drop(&mut self)

impl<T> Send for WeakPtr<T> where T: Send + Sync + WeakPtrTarget,

impl<T> Sync for WeakPtr<T> where T: Send + Sync + WeakPtrTarget,

Auto Trait Implementations

impl<T> Freeze for WeakPtr<T> where PhantomData<T>: Freeze,

impl<T> RefUnwindSafe for WeakPtr<T> where PhantomData<T>: RefUnwindSafe,

impl<T> Unpin for WeakPtr<T> where PhantomData<T>: Unpin,

impl<T> UnsafeUnpin for WeakPtr<T> where PhantomData<T>: UnsafeUnpin,

impl<T> UnwindSafe for WeakPtr<T> where PhantomData<T>: UnwindSafe,

Blanket Implementations

impl<T> Any for WeakPtr<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for WeakPtr<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for WeakPtr<T> where T: ?Sized,

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

impl<T> CloneToUninit for WeakPtr<T> where T: Clone,

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

impl<T> From<T> for WeakPtr<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for WeakPtr<T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for WeakPtr<T> where U: From<T>,

fn into(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<U> for WeakPtr<T> where U: Into<T>,

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

impl<T, U> TryInto<U> for WeakPtr<T> where U: TryFrom<T>,

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