Following the previous discussion, I've written a crate that provides an unsized enum suitable for my purposes. I've reviewed the Rustonomicon, and some of Ralf's blog posts, and I think it's sound, but I'd appreciate people looking over it. There isn't much code. The documentation page is a good place to start.
As a reminder, the motivating case was a (potential) user of Stakker wanting to do Actor<dyn Trait>
, which is problematic because Actor<A>
does something along the lines of Rc<SomeCell<enum-of-A-and-other-stuff>>
, and enum doesn't support ?Sized
right now. Whilst it might seem foolhardy to attempt something "impossible", I've learnt a lot along the way. The unsized_enum
crate is like a placemarker for what I need Rust to do for me. As Rust supports ?Sized
better, I'll adapt the crate to use those features, and the unsafe review of that crate will hopefully get easier, and at some point it will become uncontroversial to depend on it.
One thing that I realized is that there are two types of unsoundness in Rust: practical unsoundness (i.e. where the optimiser can and will break things) and theoretical unsoundness, where Ralf or whoever is trying to map out the reserved space to give themselves room to manoeuvre later on. Obviously it would be best to respect the theoretical unsoundness too, but right now it is not all settled and fixed.