An inclusive range was used with no end.
Erroneous code example:
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=]; // error: inclusive range was used with no end
}
RunAn inclusive range needs an end in order to include it. If you just need a
start and no end, use a non-inclusive range (with ..
):
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..]; // ok!
}
RunOr put an end to your inclusive range:
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=3]; // ok!
}
Run