E0586 - Error codes index
Description: Book listing all Rust error codes

# Error code E0586

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
    }

An 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!
    }

Or 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!
    }