basedrop icon indicating copy to clipboard operation
basedrop copied to clipboard

Add stable_deref_trait as an optional dependency

Open prokopyl opened this issue 2 years ago • 1 comments

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.

prokopyl avatar Jun 29 '22 09:06 prokopyl

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.

glowcoil avatar Jun 29 '22 14:06 glowcoil

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.

prokopyl avatar Feb 25 '23 19:02 prokopyl