Struct std::sync::Weak
[−]
[src]
pub struct Weak<T> where T: ?Sized {
// some 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.
Methods
impl<T> Weak<T> where T: ?Sized
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
fn main() { use std::sync::Arc; let five = Arc::new(5); let weak_five = Arc::downgrade(&five); let strong_five: Option<Arc<_>> = weak_five.upgrade(); }use std::sync::Arc; let five = Arc::new(5); let weak_five = Arc::downgrade(&five); let strong_five: Option<Arc<_>> = weak_five.upgrade();