Guarantee that mutating through Rc::as_ptr is sound?

Does std guarantee that Rc::as_ptr doesn't create a shared reference to the inside of the Rc, and hence that it's not immediate UB to mutate through this pointer? This is clearly true as a matter of implementation, see - source, but it is not explicitly documented as far as I can tell.

I don't see it listed as an explicit guarantee, but there are definitely things that rely on it, and I don't think they can realistically break this.

Could be worth a PR to document it. Same for into_raw.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.