I'm reading The Rust book and I run across this example:
fn main() {
let a = [1, 2, 3, 4, 5];
let index = 10;
let element = a[index];
println!("The value of element is: {}", element);
}
And in the book it says that after running cargo run...
The compilation didn’t produce any errors, but the program resulted in a runtime error and didn’t exit successfully.
I don't understand this. I see a compilation error, and even when I compile via cargo build or rustc src/main.rs I also see the error.
What do they mean in this example? Why is that not a compilation error, but rather a runtime one?