Struct alloc::arc::Weak 1.4.0
[−]
[src]
pub struct Weak<T: ?Sized> { /* fields omitted */ }A weak pointer to an Arc.
Weak pointers will not keep the data inside of the Arc alive, and can be
used to break cycles between Arc pointers.
A Weak<T> pointer can be upgraded to an Arc<T> pointer, but
will return None if the value has already been dropped.
For example, a tree with parent pointers can be represented by putting the
nodes behind strong Arc<T> pointers, and then storing the parent pointers
as Weak<T> pointers.
Methods
impl<T> Weak<T>[src]
impl<T: ?Sized> Weak<T>[src]
fn upgrade(&self) -> Option<Arc<T>>
Upgrades a weak reference to a strong reference.
Upgrades the Weak<T> reference to an Arc<T>, if possible.
Returns None if there were no strong references and the data was
destroyed.
Examples
use std::sync::Arc; let five = Arc::new(5); let weak_five = Arc::downgrade(&five); let strong_five: Option<Arc<_>> = weak_five.upgrade();Run
Trait Implementations
impl<T: ?Sized + Sync + Send> Send for Weak<T>[src]
impl<T: ?Sized + Sync + Send> Sync for Weak<T>[src]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T>[src]
impl<T: ?Sized + Debug> Debug for Weak<T>[src]
impl<T: ?Sized> Clone for Weak<T>[src]
fn clone(&self) -> Weak<T>
Makes a clone of the Weak<T>.
This increases the weak reference count.
Examples
use std::sync::Arc; let weak_five = Arc::downgrade(&Arc::new(5)); weak_five.clone();Run
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more