Struct alloc::rc::WeakExperimental
[-]
[+]
[src]
pub struct Weak<T> {
// some fields omitted
}A weak version of Rc<T>.
Weak references do not count when determining if the inner value should be dropped.
See the module level documentation for more.
Methods
impl<T> Weak<T>
fn upgrade(&self) -> Option<Rc<T>>
Upgrades a weak reference to a strong reference.
Upgrades the Weak<T> reference to an Rc<T>, if possible.
Returns None if there were no strong references and the data was destroyed.
Examples
use std::rc::Rc; let five = Rc::new(5i); let weak_five = five.downgrade(); let strong_five: Option<Rc<_>> = weak_five.upgrade();
Trait Implementations
impl<T> Drop for Weak<T>
fn drop(&mut self)
Drops the Weak<T>.
This will decrement the weak reference count.
Examples
use std::rc::Rc; { let five = Rc::new(5i); let weak_five = five.downgrade(); // stuff drop(weak_five); // explict drop } { let five = Rc::new(5i); let weak_five = five.downgrade(); // stuff } // implicit drop
impl<T> Clone for Weak<T>
fn clone(&self) -> Weak<T>
Makes a clone of the Weak<T>.
This increases the weak reference count.
Examples
use std::rc::Rc; let weak_five = Rc::new(5i).downgrade(); weak_five.clone();