I realize this is a terrible idea and leads to memory leaks.
However, I'm in a weird situation where I absolutely want to unsafely increment the Ref count of a Rc by 1.
How can I unsafely do this?
I realize this is a terrible idea and leads to memory leaks.
However, I'm in a weird situation where I absolutely want to unsafely increment the Ref count of a Rc by 1.
How can I unsafely do this?
Answer: Rc::into_raw()
Alternatively: std::mem::forget(some_rc.clone())
. Calling clone
on an Rc
just increments the count and forget
prevents Rc
's drop
implementation from decrementing it again.