Closed
Description
Feature gates: #![feature(arc_into_inner)]
, #![feature(rc_into_inner)]
This is a tracking issue for the Arc::into_inner
method, and (for API-consistency) also an Rc::into_inner
analogue.
The function Arc::into_inner(x)
serves as an atomic race-condition-free alternative to Arc::try_unwrap(x).ok()
. See the ACP for more details.
Public API
// alloc::sync
impl<T> Arc<T> {
/// Returns the inner value, if the `Arc` has exactly one strong reference.
/// Otherwise, `None` is returned and the `Arc` is dropped.
pub fn into_inner(this: Arc<T>) -> Option<T>;
}
and the extension to Rc
// alloc::rc
impl<T> Rc<T> {
/// Returns the inner value, if the `Rc` has exactly one strong reference.
/// Otherwise, `None` is returned and the `Rc` is dropped.
pub fn into_inner(this: Rc<T>) -> Option<T>;
}
Steps / History
- ACP: Add
Arc::into_inner
for safely discardingArc
s without calling the destructor on the inner type. libs-team#162 - Implementation:
- Final comment period (FCP)1
- Stabilization PR: Stabilize
arc_into_inner
andrc_into_inner
. #109504
Unresolved Questions
- None yet.