Rust array iterate over idices
#[allow(clippy::needless_range_loop)]
fn main() {
let numbers: [i32; 3] = [10, 11, 12];
for ix in 0..numbers.len() {
println!("{} {}", ix, numbers[ix]);
}
}
0 10
1 11
2 12
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
#[allow(clippy::needless_range_loop)]
fn main() {
let numbers: [i32; 3] = [10, 11, 12];
for ix in 0..numbers.len() {
println!("{} {}", ix, numbers[ix]);
}
}
0 10
1 11
2 12