Function alloc::arc::get_mutUnstable [-] [+] [src]

pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T>

Returns a mutable reference to the contained value if the Arc<T> is unique.

Returns None if the Arc<T> is not unique.

Examples

extern crate alloc;
use alloc::arc::{Arc, get_mut};

let mut x = Arc::new(3);
*get_mut(&mut x).unwrap() = 4;
assert_eq!(*x, 4);

let _y = x.clone();
assert!(get_mut(&mut x).is_none());