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.
The text was updated successfully, but these errors were encountered:
I have version rustc below:
rustc 1.33.0 (2aa4c46cf 2019-02-28)
I reran the example above and got the following error:
thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:5:19
note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace
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.
The text was updated successfully, but these errors were encountered: