Since the size of array types in Rust are already known at compile-time, I was wondering what might be the reason for not having reverse indexing? By reverse indexing, I mean arr[-1]
to access the last element of array arr
I can think of several reasons:
arr[-1]
implies that the index is signed, so if you have a pointer you can use indexing only to access half of the possible memory range. This can be a problem in systems programming where the highest memory bit may have a special meaning.