Hacker News new | ask | show | jobs
by kccqzy 2264 days ago
How does Rust prevent you from choosing the wrong size for an integer? It's easy to imagine a bug in Rust code in which someone is supposed to write "u8" as in this case, but didn't think carefully and just used "usize" (the most typical integer type used for indices).
2 comments

The palette memory would be bounds checked, which is the real bug.
It would prevent the out-of-bounds read and write, presumably.