Could we get guarantee that all pointer-like types have the same representation?
Rust Internals
Could we get guarantee that all pointer-like types have the same representation?
I think this code ought to be sound but I couldn't find a good resource to prove so: #[repr(C)] pub struct Foo<B> { payload: B, version: u8, } impl<'a> Borrow<Foo<&'a [u8]>> for Foo<Box<[u8]>> { fn borrow(&self) -> &Foo<&'a [u8]> { unsafe { &*(self as *const _ as *const Foo<&[u8]>) } } } IIUC it's guaranteed for pointer types to Sized objects but not for Sized even though I don't see any good reason why &T, &mut T, Box<T>, *const T, *mut T should have different represe...
0 comments
No comments yet.