Skip to content

Tracking Issue for arc_unwrap_or_clone #93610

Closed
@richard-uk1

Description

@richard-uk1

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

Unresolved Questions

  • More bikeshedding on the name is possible. Existing discussion on irlo. There seems to be consensus that the current name is good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions