News for hackers. Stuff that matters.
Re:Making Rust a Better Fit for Cheri and Other Platforms by mjw1007 on Thursday April 14, 2022 @08:14AM (#31025851)
Right, better control of the index type can help you say what you mean, and help the typechecker catch more mistakes.

If I have an array representing a single-byte lookup table, it would be nice if I could say that the array's type is array-indexed-by-u8 rather than array-indexed-by-usize.

Ada did this well: it even lets you declare an array whose index is some enumerated type.

Re:Making Rust a Better Fit for Cheri and Other Platforms by Ar-Curunir on Thursday April 14, 2022 @09:51AM (#31026992)
> _ it even lets you declare an array whose index is some enumerated type._

You can do this in Rust also: make a custom newtype wrapper for your array, and impl Index<CustomEnum> for the wrapped array.