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