from_bits_(truncate) fail with composite flags#276
Merged
KodrAus merged 8 commits intobitflags:mainfrom Apr 28, 2022
Merged
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
Author
|
This one introduced some new errors in the should fail tests, the last commit updates the corresponding .err file |
KodrAus
reviewed
Apr 23, 2022
src/lib.rs
Outdated
|
|
||
|
|
||
| let flags = Flags::from_bits(0b00000100); | ||
| assert!(flags.is_none()); |
Member
There was a problem hiding this comment.
Would this still return None if the input was 0b00000101?
was still wrong for some edge cases
Author
|
That was failing, it's now working and have added a test |
changed on last commit
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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