4 ms·
Rust has a `usize` which is 32 or 64 bits depending on the platform and also serves as the native index type for arrays and such.
by WakiMiko 8y ago
Rust has a `usize` which is 32 or 64 bits depending on the platform and also serves as the native index type for arrays and such.
- friday99 8y agoYeah, that makes sense because you need some type to span the address space and that depends on the size of the address space. That is what int is used for in go, though why they chose signed rather than unsigned is confusing. unsigned you would never have to do negative bounds checks and you can prove a lot of other useful things if you know your index is always positive.
- earenndil 8y agoI don't know how go does it, but in some languages negative indices count backwards from the rear end. E.G. myarr[-1] == myarr[myarr.length-1].