Skip to content

Commit

Permalink
Avoid unreachable overflow panics in GridAab::index().
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Nov 11, 2023
1 parent 7add952 commit 8e68198
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions all-is-cubes/src/math/grid_aab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ impl GridAab {
// * We just checked it is not negative
// * We just checked it is not greater than `self.sizes[i]`, which is an `i32`
// * We don't support platforms with `usize` smaller than 32 bits
let ixvec: Point3D<usize, _> = deoffsetted.to_usize();
let ixvec: Point3D<usize, _> = deoffsetted.map(|coord| coord as usize);

let usizes = sizes.to_usize();
let usizes = sizes.map(|s| s as usize);

// Compute index.
// Always use wrapping (rather than maybe-checked) arithmetic, because we
Expand Down

0 comments on commit 8e68198

Please sign in to comment.