Skip to content
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

Let is_all() ignore extra bits (fixes #208) #211

Merged
merged 1 commit into from May 16, 2021

Conversation

niklasf
Copy link
Contributor

@niklasf niklasf commented Feb 4, 2020

Changes is_all() to match the documented behavior in the presence of extra bits:

Returns true if all flags are currently set.

This is only relevant when unsafe from_bits_unchecked() has been used to create an instance with bits that do not correspond to any defined flag.

let extra = unsafe { Flags::from_bits_unchecked(0b1000) };
assert!(!extra.is_all());
assert!(!(Flags::A | extra).is_all());
assert!((Flags::ABC | extra).is_all());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously false, even though all flags (and one more bit) were set.

@KodrAus
Copy link
Member

KodrAus commented May 16, 2021

This looks reasonable to me! Thanks @niklasf

@KodrAus KodrAus merged commit ae4f46f into bitflags:master May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants