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>
: 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
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();