- len
Rust array of numbers, length of array
- Create array
- Get the number of elements, the length of the array using len.
- Access elements in the array using square bracket indexing.
examples/arrays/numbers/src/main.rs
fn main() { let numbers: [i8; 3] = [10, 11, 12]; println!("{:?}", numbers); println!("{}", numbers.len()); println!("{}", numbers[0]); }
[10, 11, 12] 3 10