New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to iterate through flags #28
Comments
@alexcrichton Is this something that would be accepted in the library? |
Seems plausible! |
I was just thinking about implementing this feature for some code I'm working on, if it's not already implemented. |
May be generate const array or const function that return array that contains Then implementation of iteration will be strait forward, const fn all_values_names() -> [(Flag, &'static str); N] This helps in implementation of custom serialization/deserialization (#147) or custom debug (#168). What do you think? Example of possible use-case: I want parse / generate strings like: "ab bc cd" <-> to generate string I need iteration plus names of constants in lower-case, |
This comment has been minimized.
This comment has been minimized.
In #278 we merged an implementation that allows iterating over flags and their names. It effectively looks like: pub fn iter(self) -> impl Iterator<Item = (&'static str, Self)> It effectively does what @Dushistov described, but internally. There's still design work to be done on this though, |
This is now implemented in |
Iterating over each each possible flag value would be a cool feature. I'm currently making an array with each constant value and then iterating over that.
The text was updated successfully, but these errors were encountered: