Open
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.