Hmm... you might be right, I don't have the patience to fiddle with it at the moment but the obvious route would be technically¹ UB, that's true. I think at least the
Arc<UnsafeCell<str>> version could work, since
¹ As I've mentioned before, although Rust makes no explicit guarantees about the layout of generic types that may be unsized, the fact that unsizing coercions exist effectively proves that the layout is in fact the same between different generic instantiations. IMO that guarantee should actually just be formalized, since we know it can't plausibly be false and it is already used extensively in
std with no justification. But this suggestion was shot down last time I mentioned it, and I'm not prepared to die on that hill.