fn live_neighbor_count(universe: Universe, row: u32, column: u32) -> u8 {
    let mut count = 0;

    for delta_row in [universe.height - 1, 0, 1].iter() {
        for delta_col in [universe.width - 1, 0, 1].iter() {
            if delta_row + delta_col == 0 {
                continue;
            }

            let neighbor_row = (row + *delta_row) % universe.height;
            let neighbor_col = (column + *delta_col) % universe.width;
            let idx = universe.get_index(neighbor_row, neighbor_col);
            count += universe.cells[idx] as u8;
        }
    }
    count
}
// implement method counting live neighbours of a cell in the universe
implement method counting live neighbours of a cell in the universe
implement method counting live neighbours of a cell in the universe
fn live_neighbor_count(universe: Universe, row: u32, column: u32) -> u8 {
    let mut count = 0;
    for delta_row in [universe.height - 1, 0, 1].iter() {
        for delta_col in [universe.width - 1, 0, 1].iter() {
            if delta_row + delta_col == 0 {
                continue;
            }
            let neighbor_row = (row + *delta_row) % universe.height;
            let neighbor_col = (column + *delta_col) % universe.width;
            let idx = universe.get_index(neighbor_row, neighbor_col);
            count += universe.cells[idx] as u8;
        }
    }
    count
}
fn live_neighbor_count ( universe : Universe , row : u32 , column : u32 ) -> u8 { let mut count = 0 ; for delta_row in [ universe . height - 1 , 0 , 1 ] . iter ( ) { for delta_col in [ universe . width - 1 , 0 , 1 ] . iter ( ) { if delta_row + delta_col == 0 { continue ; } let neighbor_row = ( row + * delta_row ) % universe . height ; let neighbor_col = ( column + * delta_col ) % universe . width ; let idx = universe . get_index ( neighbor_row , neighbor_col ) ; count += universe . cells [ idx ] as u8 ; } } count }
implement method counting live neighbours of a cell in the universe
implement method counting live neighbours of a cell in the universe
universe
Universe
row
u32
column
u32
universe
Universe
row
u32
column
u32