-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of #14009 : jcmoyer/rust/bitflags-complement, r=alexcrichton
I feel that this is a very vital, missing piece of functionality. This adds on to #13072. Only bits used in the definition of the bitflag are considered for the universe set. This is a bit safer than simply inverting all of the bits in the wrapped value. ```rust bitflags!(flags Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100, FlagABC = FlagA.bits | FlagB.bits | FlagC.bits }) ... // `Not` implements set complement assert!(!(FlagB | FlagC) == FlagA); // `all` and `is_all` are the inverses of `empty` and `is_empty` assert!(Flags::all() - FlagA == !FlagA); assert!(FlagABC.is_all()); ```
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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