Semantic of smart pointers
Thank you for your reply!
robofinch:
If it’s for the soundness of
unsafecode, then I think that needs are commonly fairly specific to theunsafecode.
Yes, I care about unsafe code.
robofinch:
it doesn’t seem entirely unreasonable that a non-
stdCow-like type could be copy-on-write while implementing bothAsRefandAsMut. I don’t think that would be a good idea
Yes, and that is exactly why I thought defining a smart pointer is hard. Rc, for another example, cannot implement AsMut.
robofinch:
While I’ve been assuming that there’s some reason you can’t just use
&mut [u8]
Yes, &mut [u8] can work.
robofinch:
it’d be even better if your code didn’t need to own the buffer.
Then 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.
Discussion in the ATmosphere