]> git.lizzy.rs Git - rust.git/blob - src/docs/out_of_bounds_indexing.txt
Add iter_kv_map lint
[rust.git] / src / docs / out_of_bounds_indexing.txt
1 ### What it does
2 Checks for out of bounds array indexing with a constant
3 index.
4
5 ### Why is this bad?
6 This will always panic at runtime.
7
8 ### Example
9 ```
10 let x = [1, 2, 3, 4];
11
12 x[9];
13 &x[2..9];
14 ```
15
16 Use instead:
17 ```
18 // Index within bounds
19
20 x[0];
21 x[3];
22 ```