You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to use bitflags for generated code that interacts with data in other languages, some of which are bitflags (google/flatbuffers#6098). I don't want to drop data so I'd like to use from_bits_unchecked. However, it is marked as unsafe. I'd like to submit a PR to add an option to get around this. I have two ideas:
Move the valid-bits-check to the getter: There'll be only one constructor: from_bits and the bits() getter becomes bits() -> Result<...>, unsafe bits_unchecked(), and bits_truncated()
Document why from_bits_unchecked is unsafe #200 documents that this crate uses unsafe to mean a usage issue rather than a memory issue, so maybe I could make an option to remove the unsafe altogether, and update the generated documentation appropriately?
What are your thoughts on these ideas? Does bitflags depend on the "bits are truncated to defined flags" invariant?