make Grid.set_e throw out of bounds errors
This commit is contained in:
1 parent
61e3520ede
commit
1ca2a95e1d
1 file changed
+6
-1
+6
-1
@@ -30,7 +30,12 @@ let at_e (grid : 'a t) (point : Vec2.t) =
|
||||
Option.get_exn_or "point out of bounds!" @@ at grid point
|
||||
;;
|
||||
|
||||
let set_e grid point item = Array.set grid.items (idx_of_vec2 grid.width point) item
|
||||
let set_e grid point item =
|
||||
if in_bounds grid point
|
||||
then Array.set grid.items (idx_of_vec2 grid.width point) item
|
||||
else failwith "point out of bounds!"
|
||||
;;
|
||||
|
||||
let ( .%() ) = at_e
|
||||
let ( .%()<- ) = set_e
|
||||
|
||||
|
||||
Reference in new issue
Block a user