Hello,
I want to start an iteration but not start with the first element. The goal is to browse a large grid, but to have only part of the screen (scroll screen in game)
I hit the synthase used, I saw in the examples (1 ..)
, but instead has different place it does not work.
In this exemple (x..0)
Thanks in advance,
const ROW: usize = 4;
const COLUMN: usize = 16;
pub struct Map {
pub grid: [[i32; COLUMN]; ROW],
}
impl Map {
pub fn new() -> Map {
Map {
grid: [
[0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
}
}
}
fn main ()
{
let map = Map::new();
let ( x ,y ) = ( 0i32 , 0i32 );
for (r, row) in map.grid.iter().enumerate() {
print!("{}",r);
for (c, col) in row.iter().enumerate() {
println!("{}",c);
}
}
}