basedrop
basedrop copied to clipboard
Add stable_deref_trait as an optional dependency
This allows using Basedrop's Owned
and Shared
pointer types with self-referential struct libraries. :slightly_smiling_face:
The dependency is optional and disabled by default.
I will have to give this some thought. My initial impression is that stable_deref_trait
collapses some distinctions that are currently relevant under Stacked Borrows, i.e. moving a Box<T>
or an &mut T
invalidates pointers to the T
(even though its address remains the same) whereas moving an Rc<T>
does not (I generally agree with most of what's said in https://github.com/Storyyeller/stable_deref_trait/issues/15). While both Owned
and Shared
should behave like Rc
rather than Box
or &mut T
in that regard, I'm still uneasy about exporting impls of StableDeref
, since I am not really convinced that it is a sound abstraction for building self-referential types.
After some more research and thinking on my end, I agree that in hindsight, stable_deref_trait
doesn't seem a sound enough abstraction for self-referential types.
Since we both agree it's not a great idea for now, I'll close this PR. If it's ever to be considered again, it's an easy enough change anyway.