Struct alloc::rc::Rc [] [src]

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

impl<T: ?Sized> Rc<T>

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

Unstable

: Weak pointers may not belong in this module

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

Unstable

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: ?Sized> !Send for Rc<T>

impl<T: ?Sized> !Sync for Rc<T>

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

impl<T: ?Sized> Deref for Rc<T>

type Target = T

fn deref(&self) -> &T

impl<T: ?Sized> Drop for Rc<T>

fn drop(&mut self)

impl<T: ?Sized> Clone for Rc<T>

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

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

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

fn default() -> Rc<T>

impl<T: ?Sized + PartialEq> PartialEq for Rc<T>

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

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

impl<T: ?Sized + Eq> Eq for Rc<T>

impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T>

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

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

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

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

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

impl<T: ?Sized + Ord> Ord for Rc<T>

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

impl<T: ?Sized + 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: ?Sized + Display> Display for Rc<T>

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

impl<T: ?Sized + Debug> Debug for Rc<T>

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

impl<T> Pointer for Rc<T>

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