Implicit numeric widening/coercion proposal

This would be very useful. Vec, arrays and slices indexed by one chosen type: essentially Vec<T, IndexType>, Array<T, N, IndexType> and Slice<T, IndexType>.

If this was available, it would allow moving away from pervasive use of usize to specific platform-independent types in many scenarios, and that would be a good thing. E.g. if I'm implementing a chessboard, I don't really want usize coordinates, it would be nice to be able to use u8 coordinates.

2 Likes

So that would make it Vec<T, A = Global, I = usize> I guess? Getting up there in the number of parameters (also, I think allocator should come first of the optionals, it is far far more common to use custom allocators than custom index types).

Practically I think it'd be easier to have it as BikeshedVec<I, T, A = Global>, with type Vec<T, A = Global> = BikeshedVec<usize, T, A>;.

Multiple defaulted generic parameters just doesn't go that well.

4 Likes