- iter
- enumerate
Rust array iterate indices and elements with enumerate
examples/arrays/numbers-index/src/main.rs
fn main() { let numbers: [i32; 3] = [10, 11, 12]; for (ix, number) in numbers.iter().enumerate() { println!("{ix} {}", number); } }
0 10 1 11 2 12