Expand description
A projecting version of
Weak
which allows owning a containing struct but referencing a field.
Implementations
sourceimpl<'a, T: ?Sized, Owner: 'a + Sized> Weak<T, Owner>
impl<'a, T: ?Sized, Owner: 'a + Sized> Weak<T, Owner>
pub fn erase_owner(this: Self) -> Weak<T, dyn Destruct + 'a>
sourceimpl<T: ?Sized, Owner: ?Sized> Weak<T, Owner>
impl<T: ?Sized, Owner: ?Sized> Weak<T, Owner>
sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Returns a raw pointer to the object T pointed to by this
Weak<T>.
The pointer is valid only if there are some strong references. The pointer may be dangling, unaligned, or even null otherwise.
sourcepub fn upgrade(&self) -> Option<Arc<T, Owner>>
pub fn upgrade(&self) -> Option<Arc<T, Owner>>
Attempts to upgrade the Weak pointer to
Arc<T>.
Returns None if no strong references exist.
sourcepub fn into_owner(this: Self) -> Weak<Owner>
pub fn into_owner(this: Self) -> Weak<Owner>
Consumes this projected field, returning the owning allocation.
sourceimpl<T: ?Sized, Owner: ?Sized> Weak<T, Owner>
impl<T: ?Sized, Owner: ?Sized> Weak<T, Owner>
sourcepub fn unsize<U: ?Sized, F>(
this: Self,
with: Coercion<T, U, F>
) -> Weak<U, Owner>where
T: Sized,
F: FnOnce(*const T) -> *const U,
Available on crate feature unsize only.
pub fn unsize<U: ?Sized, F>(
this: Self,
with: Coercion<T, U, F>
) -> Weak<U, Owner>where
T: Sized,
F: FnOnce(*const T) -> *const U,
unsize only.Convert this pointer with an unsizing coercion
(e.g. from T to dyn Trait or [T; N] to [T]).
sourcepub fn unsize_owner<Pwner: ?Sized, F>(
this: Self,
with: Coercion<Owner, Pwner, F>
) -> Weak<T, Pwner>where
Owner: Sized,
F: FnOnce(*const Owner) -> *const Pwner,
Available on crate feature unsize only.
pub fn unsize_owner<Pwner: ?Sized, F>(
this: Self,
with: Coercion<Owner, Pwner, F>
) -> Weak<T, Pwner>where
Owner: Sized,
F: FnOnce(*const Owner) -> *const Pwner,
unsize only.Convert this pointer with an unsizing coercion of the owner
(e.g. from T to dyn Trait or [T; N] to [T]).
Trait Implementations
sourceimpl<T, U: ?Sized, Owner: ?Sized> CoerciblePtr<U> for Weak<T, Owner>
Available on crate feature unsize only.
impl<T, U: ?Sized, Owner: ?Sized> CoerciblePtr<U> for Weak<T, Owner>
Available on crate feature
unsize only.type Pointee = T
type Pointee = T
The type we point to.
This influences which kinds of unsizing are possible. Read more
sourcefn as_sized_ptr(&mut self) -> *mut Self::Pointee
fn as_sized_ptr(&mut self) -> *mut Self::Pointee
Get the raw inner pointer.
sourceunsafe fn replace_ptr(self, ptr: *mut U) -> Self::Output
unsafe fn replace_ptr(self, ptr: *mut U) -> Self::Output
Replace the container inner pointer with an unsized version. Read more
impl<T: ?Sized, Owner: ?Sized> Send for Weak<T, Owner>where
Weak<T>: Send,
impl<T: ?Sized, Owner: ?Sized> Sync for Weak<T, Owner>where
Weak<T>: Sync,
impl<T: ?Sized, Owner: ?Sized> UnwindSafe for Weak<T, Owner>where
for<'a> &'a T: UnwindSafe,
Weak<Owner>: UnwindSafe,
Available on crate feature
std only.Auto Trait Implementations
impl<T: ?Sized, Owner: ?Sized> RefUnwindSafe for Weak<T, Owner>where
Owner: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized, Owner: ?Sized> Unpin for Weak<T, Owner>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more