You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn main() {
let a = [1, 2, 3, 4, 5];
let index = 10;
let element = a[index];
println!("The value of element is: {}", element);
}
The error reads 'index out of bounds:.....src/main.rs:6.
It is unclear why the error is on line 6, because line 6 is empty. I think the compiler message need a fix.
In the book ch 3.2 https://doc.rust-lang.org/book/ch03-02-data-types.html#invalid-array-element-access, there is an example:
The error reads
'index out of bounds:.....src/main.rs:6.It is unclear why the error is on line 6, because line 6 is empty. I think the compiler message need a fix.