Open terrorfisch opened 3 years ago
The compiler should probably be able to prove that the index is within range for almost all uses of new_unchecked
. The only usage that probably can't be checked is the lookup of CASTLES_PER_SQUARE
. I think that can actually just be a table of CastleRights
instead, forgoing the transmute
. I think this is another reason for Square
to be an enum
, since this allows the compiler to trivially prove that Square
lookups are always sound and elide the bounds checks. (I haven't tested any of these assumptions yet, but the restricted range of enum
s usually allows such optimizations.)
See #53.
This PR adds an internal unsafe function. It might not be required because the compiler maybe can prove that the bound is always met. I did not check that.