Function alloc::rc::try_unwrapExperimental
[-]
[+]
[src]
pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>>
Unwraps the contained value if the Rc has unique ownership.
If the Rc does not have unique ownership, Err is returned with the
same Rc.
Example
use std::rc::{mod, Rc}; let x = Rc::new(3u); assert_eq!(rc::try_unwrap(x), Ok(3u)); let x = Rc::new(4u); let _y = x.clone(); assert_eq!(rc::try_unwrap(x), Err(Rc::new(4u)));