Struct alloc::rc::RcStable [-] [+] [src]

pub struct Rc<T> {
    // some fields omitted
}

A reference-counted pointer type over an immutable value.

See the module level documentation for more details.

Methods

impl<T> Rc<T>

fn new(value: T) -> Rc<T>

Constructs a new Rc<T>.

Examples

use std::rc::Rc;

let five = Rc::new(5);

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

Downgrades the Rc<T> to a Weak<T> reference.

Examples

use std::rc::Rc;

let five = Rc::new(5);

let weak_five = five.downgrade();

impl<T: Clone> Rc<T>

fn make_unique(&mut self) -> &mut T

Make a mutable reference from the given Rc<T>.

This is also referred to as a copy-on-write operation because the inner data is cloned if the reference count is greater than one.

Examples

use std::rc::Rc;

let mut five = Rc::new(5);

let mut_five = five.make_unique();

Trait Implementations

impl<T> !Send for Rc<T>

impl<T> !Sync for Rc<T>

impl<T> Deref for Rc<T>

type Target = T

fn deref(&self) -> &T

impl<T> Drop for Rc<T>

fn drop(&mut self)

Drops the Rc<T>.

This will decrement the strong reference count. If the strong reference count becomes zero and the only other references are Weak<T> ones, drops the inner value.

Examples

use std::rc::Rc;

{
    let five = Rc::new(5);

    // stuff

    drop(five); // explicit drop
}
{
    let five = Rc::new(5);

    // stuff

} // implicit drop

impl<T> Clone for Rc<T>

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

Makes a clone of the Rc<T>.

This increases the strong reference count.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five.clone();

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

impl<T: Default> Default for Rc<T>

fn default() -> Rc<T>

Creates a new Rc<T>, with the Default value for T.

Examples

use std::rc::Rc;
use std::default::Default;

let x: Rc<i32> = Default::default();

impl<T: PartialEq> PartialEq for Rc<T>

fn eq(&self, other: &Rc<T>) -> bool

Equality for two Rc<T>s.

Two Rc<T>s are equal if their inner value are equal.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five == Rc::new(5);

fn ne(&self, other: &Rc<T>) -> bool

Inequality for two Rc<T>s.

Two Rc<T>s are unequal if their inner value are unequal.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five != Rc::new(5);

impl<T: Eq> Eq for Rc<T>

fn assert_receiver_is_total_eq(&self)

impl<T: PartialOrd> PartialOrd for Rc<T>

fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering>

Partial comparison for two Rc<T>s.

The two are compared by calling partial_cmp() on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five.partial_cmp(&Rc::new(5));

fn lt(&self, other: &Rc<T>) -> bool

Less-than comparison for two Rc<T>s.

The two are compared by calling < on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five < Rc::new(5);

fn le(&self, other: &Rc<T>) -> bool

'Less-than or equal to' comparison for two Rc<T>s.

The two are compared by calling <= on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five <= Rc::new(5);

fn gt(&self, other: &Rc<T>) -> bool

Greater-than comparison for two Rc<T>s.

The two are compared by calling > on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five > Rc::new(5);

fn ge(&self, other: &Rc<T>) -> bool

'Greater-than or equal to' comparison for two Rc<T>s.

The two are compared by calling >= on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five >= Rc::new(5);

impl<T: Ord> Ord for Rc<T>

fn cmp(&self, other: &Rc<T>) -> Ordering

Comparison for two Rc<T>s.

The two are compared by calling cmp() on their inner values.

Examples

use std::rc::Rc;

let five = Rc::new(5);

five.partial_cmp(&Rc::new(5));

impl<T: Hash> Hash for Rc<T>

fn hash<H: Hasher>(&self, state: &mut H)

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<T: Display> Display for Rc<T>

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

impl<T: Debug> Debug for Rc<T>

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