]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0608.md
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0608.md
1 An attempt to use index on a type which doesn't implement the `std::ops::Index`
2 trait was performed.
3
4 Erroneous code example:
5
6 ```compile_fail,E0608
7 0u8[2]; // error: cannot index into a value of type `u8`
8 ```
9
10 To be able to index into a type it needs to implement the `std::ops::Index`
11 trait. Example:
12
13 ```
14 let v: Vec<u8> = vec![0, 1, 2, 3];
15
16 // The `Vec` type implements the `Index` trait so you can do:
17 println!("{}", v[2]);
18 ```