Function std::rc::try_unwrap
[−]
[src]
pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>>
Deprecated since 1.2.0
: renamed to Rc::try_unwrap
Unwraps the contained value if the Rc<T>
`Rc
If the Rc<T>
`Rcis not unique, an
Erris returned with the same
Rc
Examples
#![feature(rc_unique)] fn main() { use std::rc::{self, Rc}; let x = Rc::new(3); assert_eq!(rc::try_unwrap(x), Ok(3)); let x = Rc::new(4); let _y = x.clone(); assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); }#![feature(rc_unique)] use std::rc::{self, Rc}; let x = Rc::new(3); assert_eq!(rc::try_unwrap(x), Ok(3)); let x = Rc::new(4); let _y = x.clone(); assert_eq!(rc::try_unwrap(x), Err(Rc::new(4)));