Struct std::rc::Weak [] [src]

pub struct Weak<T> where T: ?Sized {
    // some fields omitted
}
Unstable

: Weak pointers may not belong in this module.

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> 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> reference to an Rc<T>, if possible.

Returns None if there were no strong references and the data was destroyed.

Examples

#![feature(rc_weak)] fn main() { use std::rc::Rc; let five = Rc::new(5); let weak_five = five.downgrade(); let strong_five: Option<Rc<_>> = weak_five.upgrade(); }
#![feature(rc_weak)]

use std::rc::Rc;

let five = Rc::new(5);

let weak_five = five.downgrade();

let strong_five: Option<Rc<_>> = weak_five.upgrade();

Trait Implementations

impl<T> !Send for Weak<T> where T: ?Sized

impl<T> !Sync for Weak<T> where T: ?Sized

impl<T, U> CoerceUnsized<Weak<U>> for Weak<T> where T: Unsize<U> + ?Sized, U: ?Sized

impl<T> Drop for Weak<T> where T: ?Sized

fn drop(&mut self)

impl<T> Clone for Weak<T> where T: ?Sized

fn clone(&self) -> Weak<T>

fn clone_from(&mut self, source: &Self)

impl<T> Debug for Weak<T> where T: Debug + ?Sized

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>