Tracking Issue for `clone_from_ref`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(clone_from_ref)]
This is a tracking issue for Box::clone_from_ref, Arc::clone_from_ref, and Rc::clone_from_ref. try_* and *_in functions are under this tracking issue as well as allocator_api.
Allows creating a Box<T>/Rc<T>/Arc<T> by cloning from a &T where T: CloneToUninit. Notably, these work even when T is unsized (e.g. a slice).
Public API
// alloc::boxed
impl<T: ?Sized + CloneToUninit> Box<T> {
pub fn clone_from_ref(val: &T) -> Box<T>;
// also under feature(allocator_api)
pub fn try_clone_from_ref(val: &T) -> Result<Box<T>, AllocError>;
}
impl<T: ?Sized + CloneToUninit, A: Allocator> Box<T, A> {
// also under feature(allocator_api)
pub fn clone_from_ref_in(val: &T, alloc: A) -> Box<T, A>;
// also under feature(allocator_api)
pub fn try_clone_from_ref_in(val: &T, alloc: A) -> Result<Box<T, A>, AllocError>;
}
// alloc::rc
impl<T: ?Sized + CloneToUninit> Rc<T> {
pub fn clone_from_ref(val: &T) -> Rc<T>;
// also under feature(allocator_api)
pub fn try_clone_from_ref(val: &T) -> Result<Rc<T>, AllocError>;
}
impl<T: ?Sized + CloneToUninit, A: Allocator> Rc<T, A> {
// also under feature(allocator_api)
pub fn clone_from_ref_in(val: &T, alloc: A) -> Rc<T, A>;
// also under feature(allocator_api)
pub fn try_clone_from_ref_in(val: &T, alloc: A) -> Result<Rc<T, A>, AllocError>;
}
// alloc::sync
impl<T: ?Sized + CloneToUninit> Arc<T> {
pub fn clone_from_ref(val: &T) -> Arc<T>;
// also under feature(allocator_api)
pub fn try_clone_from_ref(val: &T) -> Result<Arc<T>, AllocError>;
}
impl<T: ?Sized + CloneToUninit, A: Allocator> Arc<T, A> {
// also under feature(allocator_api)
pub fn clone_from_ref_in(val: &T, alloc: A) -> Arc<T, A>;
// also under feature(allocator_api)
pub fn try_clone_from_ref_in(val: &T, alloc: A) -> Result<Arc<T, A>, AllocError>;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: rust-lang/libs-team#483
- Implementation: #149079
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- None yet.
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
Review the public APIs listed for Box::clone_from_ref, Rc::clone_from_ref, and Arc::clone_from_ref, then inspect implementation PR #149079 and the ACP rust-lang/libs-team#483. The remaining work is the final comment period and stabilization PR; completion is tracked by checking those items off.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100