[1] https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
That said, "what may happen in practice" can be an interesting question, but any answer cannot be relied on to be the case, because it may change at any time. Looks like my sibling already gave you a possible thing that may happen.
"A type, Src, is transmutable into a type, Dst, if every possible value of Src is a valid value of Dst."
Do you really need that much generality? How about "A type is fully mapped if all bit patterns which can be stored in the type are valid values. Fully mapped types of equal length can be transmuted into each other. References are never valid values for this operation."
u8 through u128 are fully mapped, as are i8 through i128. Floats can be considered fully mapped. Structs of those types with no padding and valid alignment are fully mapped. This is enough to handle network packets, the main use case.
The StackOverflow answer I just read comparing the two suggests bit_cast is a library function, transmute is an intrinsic. But transmute is const, and reinterpret_cast isn’t. So on some level it’s a mix of the two. Most important thing is that it’s closer to this kind of cast than a normal one.
Looking forward to using this.
Haskell's solution is elegant, powerful, and straightforward. Roles make it all work without programmer trade-off. And nowadays, Coercible has been built upon to be a metaprogramming tool (-XDerivingVia).
[1] https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-...
[2] https://www.seas.upenn.edu/~sweirich/papers/coercible-JFP.pd...