Implement iterator for all named flags#465
Implement iterator for all named flags#465KodrAus merged 3 commits intobitflags:mainfrom ssrlive:main
Conversation
Add method to iterate over all named flags.
|
This PR will implement the issue #464 |
src/traits.rs
Outdated
| } | ||
|
|
||
| /// This method will return an iterator over all named flags (including combinations). | ||
| fn all_named_flags() -> impl Iterator<Item = Self> { |
There was a problem hiding this comment.
I think we should call this iter_named and move it down to under the iter function on line 217.
We'll also need to write a concrete implementation of the iterator like the other methods do so we don't need to bump our MSRV.
KodrAus
left a comment
There was a problem hiding this comment.
Thanks for working on this @ssrlive! We'll just need to make a few changes before we can merge this. We should also add a test to the suite here: https://github.com/bitflags/bitflags/tree/main/src/tests
|
Finished all the tasks. |
and add a test case test_iter_named
|
I have fixed the |
| "Should have 5 composite flags (D, ABC, AB, AC, CB)" | ||
| ); | ||
|
|
||
| println!("All iter_named() tests passed!"); |
There was a problem hiding this comment.
I think we can remove these additional cases since they're just exercising iterator infrastructure from the standard library and aren't actually asserting on anything, but I'll do that in a follow-up.
|
Please publish a new version sooner. |
Add method to iterate over all named flags.
This test suit passed successfully
The output is