Function alloc::arc::get_mut [−] [src]

pub unsafe fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T>
Deprecated since 1.2.0

: this function is unsafe with weak pointers

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

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

This function is marked unsafe because it is racy if weak pointers are active.

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