3 ms·
I’m using rust and it’s not always clear how to solve this problem at compile time in this language either. If your array sizes are const then it’s doable but t
by bionhoward 3y ago
I’m using rust and it’s not always clear how to solve this problem at compile time in this language either. If your array sizes are const then it’s doable but that’s only a subset of the usage because often arrays must have some known variable size.
Since you seem to know how to do it, can you please tell me how to check the bounds of the arrays at compile time if the actual underlying value is not known until runtime? I guess I could make a type-level algebraic field and add, subtract, multiply, divide my generics but this seems like a huge pain in the butt.
If anyone knows how to perform comptime algebraic bounds checking in stable rust lmk
- 1970-01-01 3y agoI don't think that can ever be done with an array. Try with slices. They seem to be a fair alternative for most situations.