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
More methods to work with uncorresponding bits #327
Comments
Hi @rusty-snake 👋 Are you able to share any more details on what you're trying to do here? |
Yes, my use case are flags of ffi functions where I can only allow known safe flags. Passing known unsafe or flags added by future versions might be unsafe. Instead of silent truncating the bits I want to check and return an error. |
Ahh, so you're suggesting a function to detect whether or not there are any bits set that don't correspond to a flag? Would it be enough to write? let bits = Flags::from_bits(possibly_invalid.bits()).ok_or_else(|| "contains unrecognised bits")?; |
Yes, that would be an alternative way to implement it. |
Hi @rusty-snake. Just calling out that In #363 (comment) we're trying to come up with a fully consistent treatment of unknown bits, which might become a |
In #400 we added strict methods to the parser and formatter to work with flags that only want bit patterns that fully contain some number of defined flags. We could consider adding I've also found myself wanting a |
complement
withfrom_bits_retain
contains_uncorresponding_bits
orhas_uncorresponding_bits
The text was updated successfully, but these errors were encountered: