Skip to content

Tracking Issue for cell_get_cloned #145329

@frank-king

Description

@frank-king

Feature gate: #![feature(cell_get_cloned)]

This is a tracking issue for Cell::get_cloned for T: CloneFromCopy (e.g. Rc<T>, Arc<T>, etc.).

ACP: rust-lang/libs-team#572

Public API

/// Safety: can call `Self::clone(&*ManuallyDrop::new(ptr::read(ptr_to_self)))`
#[marker]
pub unsafe trait CloneFromCopy: Clone {}

unsafe impl<T: Copy> CloneFromCopy for T {}
unsafe impl<T: ?Sized> CloneFromCopy for Rc<T> {}
unsafe impl<T: ?Sized> CloneFromCopy for Arc<T> {}
unsafe impl<T: ?Sized> CloneFromCopy for rc::Weak<T> {}
unsafe impl<T: ?Sized> CloneFromCopy for sync::Weak<T> {}

// basically all std types that don't have indirection:
unsafe impl<T: CloneFromCopy, const N: usize> CloneFromCopy for [T; N] {}
unsafe impl<T: CloneFromCopy> CloneFromCopy for Option<T> {}
unsafe impl<T: CloneFromCopy, E: CloneFromCopy> CloneFromCopy for Result<T, E> {}
// ...

impl<T: CloneFromCopy> Cell<T> {
    pub fn get_cloned(&self) -> Self;
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

  • Implementation: #...
  • Final comment period (FCP)1
  • Stabilization PR

Unresolved Questions

  • None yet.

cc @rust-lang/libs-api @rust-lang/lang

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-radarItems that are on lang's radar and will need eventual work or consideration.S-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions