In more practical terms: What integer data type should I use for indices in a vector, length of arrays, etc?
There are lots of discussions on this topic for pre-1.0 Rust floating around on the internet and I can't find an authoritative answer on the final decision.
That would be usize
and isize
(pointer-size types, unsigned and signed). The reference says that the maximal size of an array is the maximum value of isize
such that differences of positions can be calculated.
The functions of std::Vec
use usize
for all indices, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With