Closed nicoburns closed 1 year ago
Thx for the PR. A reason for using unsafe here is performance after doing the bound checks manually via the if condition. The bounds are checked before the multiplication which could potentially panic. The call get(usize::MAX, usize::MAX)
would panic after the merge which would change the behavior of the function as documented:
Returns None if an element beyond the grid bounds is tried to be accessed.
There's no real need to have unsafe code here, and it could cause issues if the values of the rows or cols fields get out of sync with the length of the data Vec.