Closed
Description
Feature gate: #![feature(arc_unwrap_or_clone)]
This is a tracking issue for arc_unwrap_or_clone
. This feature adds methods to Rc
/Arc
to gain access to the contained value, by unwrapping if there is exactly one reference, or cloning otherwise. It is equivalent to cloning the inner value, but saves the clone operation if the caller has the only reference to the rc'd value.
Public API
impl<T: Clone> Arc<T> {
pub fn unwrap_or_clone(this: Self) -> T;
}
Steps / History
- Implementation: impl
Arc::unwrap_or_clone
#91589 - Final comment period (FCP)
- Stabilization PR
Unresolved Questions
More bikeshedding on the name is possible. Existing discussion on irlo.There seems to be consensus that the current name is good.