-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index bounds check #98
base: master
Are you sure you want to change the base?
Conversation
get_index should still vet its arguments.
Added issue #99 for this, as directed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this up @smcmurray
There is no unsafety here (not that you implied it, just noting for posterity), as indexing arrays is bounds checked in Rust.
Given that this is only for catching logic errors, I think it makes most sense to have debug assertions like this:
debug_assert!(row < self.height);
debug_assert!(column < self.width);
Can you send a PR to https://github.com/rustwasm/wasm_game_of_life too?
Thanks again @smcmurray
I like the way it's implemented in the pull request (using Consider an excersize from https://rustwasm.github.io/book/game-of-life/interactivity.html#exercises where a pulsar should be added: if a user clicks close enough to the edge of the universe, the part of the figure to be added will appear on the other side of the universe (since it's periodic). If you're fine with the approach from the PR, I can create a PR into the https://github.com/rustwasm/wasm_game_of_life repo. |
This should be handled further up the stack, before we ever call
That would be very appreciated! |
Makes sense, here is the PR: rustwasm/wasm_game_of_life#38 |
get_index should still vet its arguments.
β A similar PR may already be submitted!
Please search π among the open pull requests before creating one.
β If there isn't a similar PR, is there an open issue associated
with what this PR is trying to solve?
If not, let's create one before opening a PR. β¨
Now that you've checked, it's time to create your PR. π
Thanks for submitting! π
For more information, see the contributing guide. π«
Summary
Explain the motivation for making this change. What existing problem does the pull request solve? π€