Yes, and not just for backcompat reasons - as recently mentioned in #[repr(transparent)] – Why? wrapping something in a structure can change how it's treated in ABI. For Rc<T>
to be soundly transmuted to Rc<U>
, Rc<_>
itself would need to have an appropriate repr
, which it does not.
from_raw
and into_raw
are indeed the exact mechanism by which you should do this, and they work reliably in this case because RcBox<_>
is repr(C)
.