Closed stepancheg closed 2 months ago
Would you please create an issue about these features? I think that these features given/proposed in this PR are very useful and sometimes critical, but I have several questions.
Enumerable::ENUMERABLE_SIZE
, can you come up with a better name? I think ENUMERABLE_SIZE
is OK and acceptable but I'm also wondering is there a clearer name. Also I'm not sure what's the best behavior when it exceeds usize::MAX
, maybe failing at compile is the best option.Enumerable::enumerable_index
/Enumerable::enumerable_from_index
, maybe we should call them Enumerable::enumerable_until_index
and Enumerable::enumerable_from_index
? Also I think we should give them default implementations.Thank you for your contribution! Very happy to see you in this repo again.
I've created issue #26 for this PR.
For Enumerable::enumerable_index
and Enumerable::enumerable_from_index
, I misunderstood their purpose in my last comment. I'll discuss them in #27.
Associated constant for the number of values in this enumerable. If the number exceeds
usize::MAX
, accessing the constant fails at compile time.This is useful to create a compact storage to map all the values:
I chose name
ENUMERABLE_SIZE
notSIZE
to avoid confusion with possible other meaning ofSIZE
(for example,for
u32`SIZE
could also mean size in bytes).Follow-up to this PR would be implementing:
Enumerable::enumerable_index
to map enumerable value tousize
indexEnumerable::enumerable_from_index
for the opposite operation