Struct std::sync::Weak [] [src]

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

: Weak pointers may not belong in this module.

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>>

Unstable

: Weak pointers may not belong in this module.

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

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

use std::sync::Arc;

let five = Arc::new(5);

let weak_five = five.downgrade();

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

Trait Implementations

impl<T> Send for Weak<T> where T: Send + Sync + ?Sized

impl<T> Sync for Weak<T> where T: Send + Sync + ?Sized

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

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

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

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

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

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

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

fn drop(&mut self)