{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreibfn4ryzhixszobreohixqmex7xeqz43hyksdtpkbcdoyt5tpjeqy",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mm7xs6gm23f2"
},
"path": "/t/semantic-of-smart-pointers/24345#post_3",
"publishedAt": "2026-05-19T15:15:10.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "Thank you for your reply!\n\nrobofinch:\n\n> If it’s for the _soundness_ of `unsafe` code, then I think that needs are commonly fairly specific to the `unsafe` code.\n\nYes, I care about unsafe code.\n\nrobofinch:\n\n> it doesn’t seem _entirely_ unreasonable that a non-`std` `Cow`-like type could be copy-on-write while implementing both `AsRef` and `AsMut`. I don’t think that would be a _good_ idea\n\nYes, and that is exactly why I thought defining a smart pointer is hard. Rc, for another example, cannot implement AsMut.\n\nrobofinch:\n\n> While I’ve been assuming that there’s some reason you can’t just use `&mut [u8]`\n\nYes, `&mut [u8]` can work.\n\nrobofinch:\n\n> it’d be even better if your code didn’t need to own the buffer.\n\nThen if the struct containing the reference needs to be moved around, it will be very hard for the library user to maintain the code, I guess.",
"title": "Semantic of smart pointers"
}