I've just started coding in rust for a few days now and have stumbled upon this case here that I don't understand
struct Foo {
arr: [u8; 5]
}
fn main() {
let foo = Foo{ arr: [0; 5] };
let bar = &foo;
println!("{}", bar.arr[100]);
}
Why does this code compile? Can't the compiler see that there is an out-of-bounds error there? It can detect it when i try to print foo.arr[100], so what gives?