Tracking Issue for `cell_get_cloned`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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: https://github.com/rust-lang/libs-team/issues/572
Public API
/// Safety: can call `Self::clone(&*ManuallyDrop::new(ptr::read(ptr_to_self)))`
#[marker]
pub unsafe trait CloneFromCell: Clone {}
// Can't do this, unsound
// unsafe impl<T: Copy> CloneFromCell for T {}
unsafe impl<T: ?Sized> CloneFromCell for Rc<T> {}
unsafe impl<T: ?Sized> CloneFromCell for Arc<T> {}
unsafe impl<T: ?Sized> CloneFromCell for rc::Weak<T> {}
unsafe impl<T: ?Sized> CloneFromCell for sync::Weak<T> {}
// basically all std types that don't have indirection:
unsafe impl<T: CloneFromCell, const N: usize> CloneFromCell for [T; N] {}
unsafe impl<T: CloneFromCell> CloneFromCell for Option<T> {}
unsafe impl<T: CloneFromCell, E: CloneFromCell> CloneFromCell for Result<T, E> {}
// ...
impl<T: CloneFromCell> Cell<T> {
pub fn get_cloned(&self) -> Self;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Implementation: https://github.com/rust-lang/rust/pull/145685
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Should this remain
get_clonedor move to theCloneimpl forCell? https://github.com/rust-lang/libs-team/issues/572#issuecomment-3180625110 - Concern: the soundness conditions here are extremely tricky to get right. We need to have a warning about this.
- The soundness requirement on
CloneFromCopyas stated above is likely wrong.
cc @rust-lang/libs-api @rust-lang/lang
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the tracking issue, the Cell::get_cloned API sketch, and implementation PR 145685. Read the linked libs-team discussion and unresolved questions before making changes, especially the proposed method location and soundness requirements. Done means the implementation, final comment period, and stabilization PR have been completed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100