See the example:
use std::{mem::{transmute_copy}};
fn main() {
let s = String::from("hello world");
let (a, b, c) = unsafe { transmute_copy::<_, (usize, usize, usize)>(&s) };
let ((a1, a2, a3, a4, a5, a6, a7, a8), d, e) = unsafe {
transmute_copy::<_, (
(u8, u8, u8, u8, u8, u8, u8, u8),
usize,
usize
)>(&s)
};
println!("0x{:x} 0x{:x} 0x{:x}", a, b, c);
println!(
"0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x} 0x{:x}",
a1, a2, a3, a4, a5, a6, a7, a8, d, e
);
}
The output:
0x55ed87f769d0 0xb 0xb
0xb 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x55ed87f769d0 0xb
0x55ed87f769d0
is the address/the memory location, I think.
Why in the first print, it's at the first 8 bytes, while in the second print, it's at the second 8 bytes?