I've got an
enum with ~30 variants, each of which I will be associating with a field of a struct to retrieve the field's value. But I will only ever need a certain number (~15-20) of the variants/fields for each of many iterations to be run, so I'm looking to use a Set to only store the fields I want to retrieve per iteration. I only need to configure the Set once, and I only intend to access each variant exactly once per iteration (using a memoized intermediary).
It seems like overkill to use a
enums are already distinct without hashing. Though I suppose
HashMap does allow for custom hashing, so could I switch to an unhashed version as long as all keys are guaranteed to be unique?
BTreeSet seems to have drawbacks, but would also technically work. The other option (and the one I'm leaning towards) would be to custom implement around a
Vec. The work to check appends would be minimal (if !vec.contains() then append), iterating its held variants would be a breeze, and I don't care about order of insertion/retrieval...
Any suggestions would be greatly appreciated. Thanks!