{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreig56bajmbczkn7iuiukhpcmcyhfynwenygzta6eto5qmskou3dvqu",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mgdfjew2bv72"
},
"path": "/t/interior-mutability-and-safety-of-ownership-transfer-in-rust/24055#post_5",
"publishedAt": "2026-03-05T16:10:38.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "Eh2406:\n\n> If \"non-owning\" includes `&mut Vec<T>`, then no. What if the `Vec<T>` is at capacity and both copies call `push`? Then you get a double free . More generally `&mut` means exclusive, so `&mut v1[0]` and `&mut v2[0]` is UB on its own.\n>\n> If by \"non-owning\" you mean `&Vec<T>`, you will need better languish lawyers then me.\n\nNo, this is not what I mean. In my case there are two bitwise-equal copies of the same `Vec` (pointer, len and capacity are all equal), but one is essentially a \"non-owning\" `ManuallyDrop<Box<Vec<T>>>` and the other in an \"owning\" `Box<Vec<T>>`. This is quite typical in unsafe low-level data structures dealing with manually allocated memory*, but it is usually not possible for both instances to be observable externally.\n\n(*) temporarily, inside a single function",
"title": "Interior mutability and safety of ownership transfer in Rust"
}