Struct std::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

fn main() { use std::rc::Rc; let five = Rc::new(5); }
use std::rc::Rc;

let five = Rc::new(5);

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

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

Examples

fn main() { use std::rc::Rc; let five = Rc::new(5); let weak_five = five.downgrade(); }
use std::rc::Rc;

let five = Rc::new(5);

let weak_five = five.downgrade();

impl<T> Rc<T> where T: Clone

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

fn main() { use std::rc::Rc; let mut five = Rc::new(5); let mut_five = five.make_unique(); }
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

fn main() { use std::rc::Rc; { let five = Rc::new(5); // stuff drop(five); // explicit drop } { let five = Rc::new(5); // stuff } // implicit drop }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five.clone(); }
use std::rc::Rc;

let five = Rc::new(5);

five.clone();

fn clone_from(&mut self, &Rc<T>)

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

fn default() -> Rc<T>

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

Examples

fn main() { use std::rc::Rc; use std::default::Default; let x: Rc<i32> = Default::default(); }
use std::rc::Rc;
use std::default::Default;

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

impl<T> PartialEq<Rc<T>> for Rc<T> where T: PartialEq<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

fn main() { use std::rc::Rc; let five = Rc::new(5); five == Rc::new(5); }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five != Rc::new(5); }
use std::rc::Rc;

let five = Rc::new(5);

five != Rc::new(5);

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

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

fn assert_receiver_is_total_eq(&self)

impl<T> PartialOrd<Rc<T>> for Rc<T> where T: PartialOrd<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

fn main() { use std::rc::Rc; let five = Rc::new(5); five.partial_cmp(&Rc::new(5)); }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five < Rc::new(5); }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five <= Rc::new(5); }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five > Rc::new(5); }
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

fn main() { use std::rc::Rc; let five = Rc::new(5); five >= Rc::new(5); }
use std::rc::Rc;

let five = Rc::new(5);

five >= Rc::new(5);

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

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

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

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

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

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

fn main() { use std::rc::Rc; let five = Rc::new(5); five.partial_cmp(&Rc::new(5)); }
use std::rc::Rc;

let five = Rc::new(5);

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

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

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

fn hash_slice<H>(&[Rc<T>], &mut H) where H: Hasher, Rc<T>: Sized

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

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

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

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

impl<T> Borrow<T> for Rc<T>

fn borrow(&self) -> &T