Why doesn't Rc::into_unwrapped() exist?

Rc::try_unwrap() consumes an Rc and returns the contained value if the Rc had no other strong references. If the Rc did have other strong references, it returns an error result containing the consumed Rc.

Meanwhile, there's Rc::make_mut(&mut self), which is implemented if T: Clone, and clones the inner value if necessary to get to the no other strong references state.

So by that logic, why not make Rc::into_unwrapped() for T: Clone, and have it always return the contained value, cloning if necessary?

I would think most would just clone. If a programmer sees the performance benefit they can easily write;


Right, so not enough demand yet to add.

Also, I just realized that try_unwrap() only just became available in stable too.