-
Notifications
You must be signed in to change notification settings - Fork 162
from_bits accepts non existing flags #275
Copy link
Copy link
Closed
Description
#[test]
fn test_from_bits_edge_cases() {
bitflags! {
struct Flags: u8 {
const A = 0b00000001;
const BC = 0b00000110;
}
}
let flags = Flags::from_bits(0b00000100);
assert!(flags.is_none());
}Unless I'm missing something this test should pass but it fails cause from_bits accepts flags that are not declared.
This is related to this issue in the implementation of iterators in this PR #204 (comment) Using from_bits instead of from_bits_unchecked should allow to produce any valid flags that are not a combination of other flags but at the moment from_bits seems to accept any flag that is included in a combination even if it's not declared. I can try to send a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels