Clone RefCell contents

Is the a way of cloning the contents of a RefCell without consuming the original ?

I see there is something like


However, that requires a unsafe block. Is there a way without having to resort to that ?

I think refcell.borrow().clone() should work.


What eko said, or just refcell.clone().into_inner().

Ok, Thanks. I must have been getting confused. I thought it was cloning a ref on the borrow.