rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.73k stars 208 forks source link

Universe::get_index doesn't bounds check #99

Open smcmurray opened 5 years ago

smcmurray commented 5 years ago

Universe::get_index() is almost certainly doing the wrong thing if you give it a row or column that is out of bounds.

You may argue that this little example never does that. But this little example is meant to be expanded upon. One little change will make it more resilient for future code additions.

Alternatively, you could (perhaps should) return a Result instead of edge-wrapping.