Struct std::rc::Weak
[−]
[src]
pub struct Weak<T> where T: ?Sized {
// some fields omitted
}
Unstable
: Weak pointers may not belong in this module.
Methods
impl<T> Weak<T> where T: ?Sized
fn upgrade(&self) -> Option<Rc<T>>
Unstable
: Weak pointers may not belong in this module.
Upgrades a weak reference to a strong reference.
Upgrades the Weak<T>
`Weakreference to an
` reference to an Rc<T>
`Rc
Returns None
`None` if there were no strong references and the data was
destroyed.
Examples
#![feature(alloc)] fn main() { use std::rc::Rc; let five = Rc::new(5); let weak_five = five.downgrade(); let strong_five: Option<Rc<_>> = weak_five.upgrade(); }use std::rc::Rc; let five = Rc::new(5); let weak_five = five.downgrade(); let strong_five: Option<Rc<_>> = weak_five.upgrade();