[Pre-RFC] Implicit number type widening

I'm not sure whether I want indexing by signed numbers (though that'd be the easiest way to make the change work without compiler work), but can you elaborate? The thrust of the thread here has seemed to me as being about how indexing taking more types would be ok since it's already partial, and it's non-obvious to me that indexing failures from an index being too small are fundamentally different from an index being too large. Getting None from v.get(i+1) at the end of a slice and getting None from v.get(i-1) at the beginning of the slice don't seem all that different, for example.

And because indexes are already restricted to isize::MAX as usize, indexing by isize only takes one check for in-bounds, the same as usize.

(To pre-emptively avoid a potential misunderstanding: I definitely want v[-1] to panic because of the off-by-one the same as v[v.len()] because of the off-by-one errors. I do not want v[-1] to give the last item in the slice.)

7 Likes