]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0586.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0586.md
1 An inclusive range was used with no end.
2
3 Erroneous code example:
4
5 ```compile_fail,E0586
6 fn main() {
7     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
8     let x = &tmp[1..=]; // error: inclusive range was used with no end
9 }
10 ```
11
12 An inclusive range needs an end in order to *include* it. If you just need a
13 start and no end, use a non-inclusive range (with `..`):
14
15 ```
16 fn main() {
17     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
18     let x = &tmp[1..]; // ok!
19 }
20 ```
21
22 Or put an end to your inclusive range:
23
24 ```
25 fn main() {
26     let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
27     let x = &tmp[1..=3]; // ok!
28 }
29 ```