How to truncate if const _ = !0; was used #443
Labels
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-bitflags/bitflags#443
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm in the situation where a bitflags type from a third-party crate uses
const _ = !0;(i.e. I can not modify thebitflags!definition and add/remove flags). I need thecomplementof all known/defined flags. However I do not see a way totruncate/... theses flags in this case or do acomplement_definedor accessFooFlags::_or whatever. I can not even tell if there are extra bits set.If the library is using an unnamed
_ = !0flag then there aren't really any unknown flags or bits so to speak. The underlying definition could introduce new flags before the library adds them, so any set bits should be considered valid.Something you can do though is get a flags value that only includes named flags by iterating over them, like in this example:
We could maybe define a
Flags::all_namedconstructor that produced this value, and optimize it for thebitflags!macro.