cell grid robust against null dimensions

Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
This commit is contained in:
Fabrizio Iannetti 2023-03-17 19:21:21 +01:00
parent 6fb0761911
commit c805cc94d3
1 changed files with 2 additions and 2 deletions

View File

@ -38,8 +38,8 @@ impl CellGrid {
y, y,
width, width,
height, height,
num_x, num_x: if num_y > 0 { num_x } else { 0 }, // if one dimension is 0, both shall be 0
num_y, num_y: if num_x > 0 { num_y } else { 0 }, // if one dimension is 0, both shall be 0
pos_x: 0, pos_x: 0,
pos_y: 0, pos_y: 0,
curr: Cell {x, y, width, height, pos_x: 0, pos_y: 0} curr: Cell {x, y, width, height, pos_x: 0, pos_y: 0}