Closed CAESIUS-TIM closed 1 year ago
https://github.com/rust-embedded/book/blob/22bca3d0f6e9b9b556689b54ce96f25b46ecd1b3/src/start/panicking.md?plain=1#L90
The given example doesn't effectively show that in Rust, indices start from 0; it might even give the impression that indices begin at 1.
A common mistake is forgetting to subtract 1, as seen here: Right: let i = xs.len() - 1; Wrong: let i = xs.len();
let i = xs.len() - 1;
let i = xs.len();
https://github.com/rust-embedded/book/blob/22bca3d0f6e9b9b556689b54ce96f25b46ecd1b3/src/start/panicking.md?plain=1#L90
The given example doesn't effectively show that in Rust, indices start from 0; it might even give the impression that indices begin at 1.
A common mistake is forgetting to subtract 1, as seen here: Right:
let i = xs.len() - 1;
Wrong:let i = xs.len();