Support prefix transmutes in transmute!
et al
#1852
Labels
experience-hard
This issue is hard, and requires a lot of experience
help wanted
Extra attention is needed
Syntax
We should be able to add special syntax so that existing uses of
transmute!
are unaffected, while users are able to opt-in to prefix transmute behavior:Design
Currently, we require that
mem::transmute::<T, U>()
compiles, which ensures thatsize_of::<T>() == size_of::<U>()
. If we instead introduce aunion MaxSizesOf<T, U>
type, then we can instead require thatmem::transmute::<MaxSizesOf<T, U>, T>()
compiles. This ensures thatsize_of::<T>() >= size_of::<U>()
, which ensures that it's sound to perform a prefix transmute fromT
toU
.The text was updated successfully, but these errors were encountered: