Re:Nearly All Binary Searches and Mergesorts Are Broken (2006)
by Sharlin on Sunday November 06, 2022 @09:34AM
(#33493026)
The type that’s meant for indexing in C and C++ is called `size_t`. It is pointer-sized. In Rust it’s called `usize` and Rust does not have implicit conversions, so if you accidentally use too narrow an integer type to compute an index, at least Rust forces you to add an explicit cast somewhere.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006)
by tinyspacewizard on Sunday November 06, 2022 @11:59AM
(#33494611)
I've seen libraries that add a size_t type as an alias to int on certain systems. Rust gets it right here.
Casts from int to pointer should be explicit.
We are enamoured with programmer convenience at the expense of the safety of our systems. It’s unprofessional and we should all aim to fix it.