Is there a way to move an object from an Rc<T>
when the count is 1
? I am thinking about how one would implement:
fn take_ownership<T>(shared: Rc<T>) -> Result<T, Rc<T>> { ... }
The semantics would be that you get T
if the count is 1
and you get back shared
otherwise so you can try again later.
The standard library provides the
Rc::try_unwrap
function: