How and why does Rust convert &[&u8; 2]
to &[&u8]
in this code? I thought originally it must be doing some kind of Deref
shenanigans, but that doesn't seem to be the case.
struct Example<'a, 'b: 'a> {
params: &'a [&'b u8],
}
fn main() {
let a = 2u8;
let b = 3u8;
let x = &[&a, &b];
let st = Example { params: x };
println!(" Size of x: {} ", std::mem::size_of_val(&x));
println!(" Size of &[&u8; 2]: {} ", std::mem::size_of::<&[&u8; 2]>());
println!(" Size of Example: {} ", std::mem::size_of::<Example>());
}
// Console out:
// Size of x: 8
// Size of &[&u8; _]: 8
// Size of Example: 16