the.bay.news

Cloning an Rc from its pointer

The Rust Programming Language Forum
Cloning an Rc from its pointer
let the_rc: Rc<u32> = todo!(); let p = the_rc.as_ptr(); unsafe fn clone_from<T>(p:*const T) -> Rc<T> { todo!() } Note the above deliberately uses .as_ptr() and not into_raw() since the pointer is in reality put into a Copy struct and I can not keep track of the number of copies being made. Hence into_raw would end up with a bungled strong count. The unsafe precondition of clone_from is that the Rc is still alive. I do not take a &Rc<T> because the original Rc needs to be movable after the p...

let the_rc: Rc<u32> = todo!(); let p = the_rc.as_ptr(); unsafe fn clone_from<T>(p:*const T) -> Rc<T> { todo!() } Note the above deliberately uses .as_ptr() and not into_raw()…

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.