# Struct alloc::rc::Weak [−] [src]

    pub struct Weak<T: ?Sized> {
        // 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: ?Sized> 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(5);

    let weak_five = Rc::downgrade(&five);

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

### `impl<T> Weak<T>`

#### `fn new() -> Weak<T>`

Unstable (`downgraded_weak` #30425)

: recently added

Constructs a new `Weak<T>` without an accompanying instance of T.

This allocates memory for T, but does not initialize it. Calling Weak<T>::upgrade() on the return value always gives None.

# Examples

    #![feature(downgraded_weak)]

    use std::rc::Weak;

    let empty: Weak<i64> = Weak::new();

## Trait Implementations

### `impl<T: ?Sized> !Send for Weak<T>`

### `impl<T: ?Sized> !Sync for Weak<T>`

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

### `impl<T: ?Sized> Drop for Weak<T>`

#### `fn drop(&mut self)`

### `impl<T: ?Sized> Clone for Weak<T>`

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

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

### `impl<T: ?Sized + Debug> Debug for Weak<T>`

#### `fn fmt(&self, f: &mut Formatter) -> Result`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize`)