Struct std::rc::Rc [] [src]

pub struct Rc<T> where 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

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

let five = Rc::new(5);

impl<T> Rc<T> where T: ?Sized

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

Unstable

: Weak pointers may not belong in this module

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

Examples

#![feature(alloc)] 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

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

#![feature(alloc)] 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> where T: ?Sized

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

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

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

type Target = T

fn deref(&self) -> &T

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

fn drop(&mut self)

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

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

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

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

fn default() -> Rc<T>

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

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

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

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

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

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> Ord for Rc<T> where T: Ord + ?Sized

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

impl<T> Hash for Rc<T> where T: Hash + ?Sized

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

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

impl<T> Display for Rc<T> where T: Display + ?Sized

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

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

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

impl<T> Pointer for Rc<T>

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

impl<T> Borrow<T> for Rc<T> where T: ?Sized

fn borrow(&self) -> &T