Open kpreid opened 2 months ago
Further use cases:
rand
or arbitrary
. We should not add dependencies for this purpose, but we should make sure it's easy and provide examples of doing so.to_index()
, incrementing or decrementing, then from_index()
. Or, producing an iterator starting or ending at a specific value.nth()
would provide efficient T::exhaust().skip(n)
for free.
Add a trait & derive for indexable types. Something like:
This allows building fixed-size, exhaustive mapping data structures like
enum-map
, but with the nestability thatexhaust::Exhaust
supports.Exhaust iterators for this type should also override
position()
andnth()
to be O(1), but we do not want this to be the sole interface because it may be undesirable to allocate the iterator first, and because they are tedious to use and have anunwrap()
.