-
Notifications
You must be signed in to change notification settings - Fork 144
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
from_bits_(truncate) fail with composite flags #276
Conversation
When a bitflags type contains composite flags like: ```rs bitflags! { struct Flags: u8 { const A = 0b00000001; const BC = 0b00000110; } } ``` from_bits and from_bits_truncate would not work as expected allowing flags that are not declared. Fixes bitflags#275
extra brace commited accidentally due to partial staging
serde:: doesn't work on tests on CI
This one introduced some new errors in the should fail tests, the last commit updates the corresponding .err file |
src/lib.rs
Outdated
|
||
|
||
let flags = Flags::from_bits(0b00000100); | ||
assert!(flags.is_none()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this still return None
if the input was 0b00000101
?
was still wrong for some edge cases
That was failing, it's now working and have added a test |
changed on last commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @arturoc! This looks good to me.
We need to keep the paths for Some
and None
mangled like they were, but I'll submit a follow-up that does that.
When a bitflags type contains composite flags like:
from_bits and from_bits_truncate would not work as expected allowing flags that are not declared.
Fixes #275