Peternator7 / strum

A small rust library for adding custom derives to enums
https://crates.io/crates/strum
MIT License
1.8k stars 151 forks source link

Implement `Iterator` for EnumTable #329

Closed rockboynton closed 8 months ago

rockboynton commented 9 months ago

See the API for enum_map::EnumMap. This would allow for things such as

for (id, value) in my_enum_table {
    // do stuff
}
Peternator7 commented 9 months ago

I wasn't aware that crate existed! I wanted to get iterator into the initial version, but there was already a lot going on.

So it's on my radar, but given that other crate exists, what makes EnumTable a better choice than enum_map?

rockboynton commented 9 months ago

I think enum_iter provides mostly a subset of strum, except in this case. It would be nice to add this feature to strum to allow me to remove a dependency. For me, the .all_ok() method of EnumTable makes it so I can use the ? operator when building the table with from_closure which is a big limitation of enum_map.

That's my 2 cents. Since EnumTable now exists, adding the associated iterator methods seems like a natural extension

rockboynton commented 9 months ago

fwiw I would also say I think the API of enum_map's EnumMap<MyEnum, V> makes more sense than a generated MyEnumTable<V> and would match the API of similar rust collections better

Peternator7 commented 9 months ago

I'm more inclined to think that given enum_map exists, it just makes more sense to deprecate EnumTable since it's generally a more feature complete implementation.

Peternator7 commented 8 months ago

I'm going to move toward deprecating EnumTable from strum. Thanks for making me aware of enum_map. I think it's a better solution and there isn't a lot of reason for both to exist.

rockboynton commented 8 months ago

Sounds good, it would be improvement to that crate instead