You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using this crate for "incremental" options for an application I'm writing - to that end, I need to iterate over the set flags in the structure.
I've started implementing an iterator which simply goes through the bits, right to left and yields an Option<BitFlag> for each, signaling whether it is set or not - to achieve this, having a length method in the generated structure would help immensely since it allows me to know when I've reached the structure end.
Would there be interest in implementing this?
The text was updated successfully, but these errors were encountered:
This unfortunately starts to get tricky when you have flags that cover multiple bits, which is something that bitflags allows even if it's not the most common case. I think that's what's stalled most attempts to implement a general iterator for all kinds of flags. The latest attempt is #278, which seems pretty close.
Since #278 is merged we can now write flags.iter().count(). I think this is nice and clear and communicates that the length you get is calculated rather than intrinsic.
We're currently working towards a 2.0.0 release that will include this and some other breaking changes for better future-proofing. If you'd like to keep track of where that's at you can follow along #262
I'm currently using this crate for "incremental" options for an application I'm writing - to that end, I need to iterate over the set flags in the structure.
I've started implementing an iterator which simply goes through the bits, right to left and yields an
Option<BitFlag>
for each, signaling whether it is set or not - to achieve this, having a length method in the generated structure would help immensely since it allows me to know when I've reached the structure end.Would there be interest in implementing this?
The text was updated successfully, but these errors were encountered: