I wrap a usize
value into a struct that allows me to handle overflow behaviour (with custom max value). I implement all the Sub/Add
traits to make it behave like a primitive type. It's great! But I'm missing two things:
- indexing a slice from that custom type (
myslice[custom_usize]
). Apparently implementingSliceIndex
is the way to go, but this appears to only be possible withincore::
(because it requires my type to implement acore::
private trait:Sealed
). - support ranges. I want to be able to do
for x in custom_usize_1..custom_usize_2
. No idea how to do that.
Any idea if any of these things are possible?