-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
When using from_raw
/into_raw
functions with Rc
, you often want to obtain a new reference to a raw pointer, without taking ownership. At the moment you have to do this dance:
fn clone_raw<T>(ptr: *const T) -> Rc<T> {
let result = unsafe { Rc::from_raw(ptr) };
::std::mem::forget(result.clone());
result
}
This is quite error prone and makes little sense to anyone trying to read the code. It would be better if the standard library had clone_raw
built in for Rc
and Arc
, and possibly for their weak variants.
asherkin, zakarumych, thomcc, HTGAzureX1212, lo48576 and 1 more
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.