Function alloc::rc::get_mutExperimental [-]  [+] [src]

pub fn get_mut<'a, T>(rc: &'a mut Rc<T>) -> Option<&'a mut T>

Returns a mutable reference to the contained value if the Rc has unique ownership.

Returns None if the Rc does not have unique ownership.

Example

use std::rc::{mod, Rc};
let mut x = Rc::new(3u);
*rc::get_mut(&mut x).unwrap() = 4u;
assert_eq!(*x, 4u);
let _y = x.clone();
assert!(rc::get_mut(&mut x).is_none());