Support prefix transmutes in `transmute!` et al
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 179
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 29
Description
### 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:
```rust
// Current behavior, remains the default.
transmute!(a);
// Opt-in to prefix transmutation (exact syntax to be bikeshedded)
transmute!(@prefix a);
```
### Design
Currently, we require that `mem::transmute::()` compiles, which ensures that `size_of::() == size_of::()`. If we instead introduce a `union MaxSizesOf` type, then we can instead require that `mem::transmute::, T>()` compiles. This ensures that `size_of::() >= size_of::()`, which ensures that it's sound to perform a prefix transmute from `T` to `U`.
Contributor guide
Assessment
This issue has not been assessed yet.