strum icon indicating copy to clipboard operation
strum copied to clipboard

Rename EnumIter => VariantIterator

Open Peternator7 opened this issue 4 years ago • 6 comments

Evaluating the naming scheme and value of all the macros used in strum. Some are more or less redundant such as ToString now that Display exists.

This is a tracking issue to solicit feedback about the usefulness of EnumIter and whether it should be kept and if so, what it's name should be.

Peternator7 avatar Oct 07 '20 16:10 Peternator7

Well, I'm trying to use it, per the example, and it's not found. Was it taken out already? Is there a replacement?

 use strum::IntoEnumIterator;
 use strum::EnumIter;
   |     ^^^^^^^^^^^^^^^ no `EnumIter` in the root

Cargo.toml:

[dependencies]
strum = "0.19"
strum_macros = "0.19"

I really need this to deal with some large machine-generated enums.

John-Nagle avatar Nov 03 '20 23:11 John-Nagle

Hey John,

You can do either this:

[dependencies]
strum = { version = "0.19", features = ["derive"] }

or if you want to leave the Cargo.toml as is, you should update the imports to be this.

use strum::IntoEnumIterator;
use strum_macros::EnumIter;

Peternator7 avatar Nov 03 '20 23:11 Peternator7

Thanks. Just figured that out. Suggest updating documentation.

John-Nagle avatar Nov 04 '20 00:11 John-Nagle

This macro is the original reason I found out about strum, and added it as a dependency. It's one of the most important features of the crate, IMO!

linclelinkpart5 avatar Nov 09 '20 21:11 linclelinkpart5

I think this is an important feature missing from the main rust library, and I'm glad you've done it. The naming seems correct. FTR I'm a beginner in rust and I currently have a use for EnumIter.

Nioub avatar Nov 15 '20 13:11 Nioub

IMO the name should be the same as the trait it implements, this is common throughout the rust ecosystem so much so that CLion's rust plugin relies on this for derive macros in order to increase analysis speed.

Buzzec avatar Apr 06 '21 04:04 Buzzec