Hopefully it could also support e.g. &U { t: *t, marker: PhantomData }.
Unfortunately there may be an ambiguity in the mutable case:
struct S(i32);
fn f(x: &mut i32) {
let s = &mut S(*x);
s.0 = 1;
}
fn main() {
let mut x = 0;
f(&mut x);
println!("{}", x);
}
This compiles today and prints 0. If &mut S(*x) where made equivalent to mem::transmute::<&mut i32, &mut S>(x) then this would begin printing 1 instead.
I’ve heard whispers that people are souring on `as`. Does that mean using `as` here is out of the question? It has the benefit of not conflicting with existing compilable code.