Comments (5)
Hi @rusty-snake. Just calling out that 2.3.3
slightly alters the behavior of the !
operator that affects flags with bits that only partially correspond to a known flag. I'm not sure if that will affect you, but wanted to draw your attention to it.
In #363 (comment) we're trying to come up with a fully consistent treatment of unknown bits, which might become a 3.0.0
release. That would let us include some new inherent methods for detecting and truncating them if you wish.
from bitflags.
Hi @rusty-snake
from bitflags.
Yes, my use case are flags of ffi functions where I can only allow known safe flags. Passing known unsafe or flags added by future versions might be unsafe. Instead of silent truncating the bits I want to check and return an error.
from bitflags.
Ahh, so you're suggesting a function to detect whether or not there are any bits set that don't correspond to a flag? Would it be enough to write?
let bits = Flags::from_bits(possibly_invalid.bits()).ok_or_else(|| "contains unrecognised bits")?;
from bitflags.
Yes, that would be an alternative way to implement it.
from bitflags.
Related Issues (20)
- Policy for unstable dependencies HOT 10
- insert_if() and remove_if() HOT 2
- feat: Add Security Policy HOT 2
- Methods on generated flags types not being detected as const HOT 6
- can't use private derive macros HOT 6
- bitflags v2.2 incompatibility with mysql_common HOT 3
- Bitflags reverses order of multiline doc comments HOT 1
- Allow opting-out of `InternalBitFlags` `fmt`/`FromStr` impls? HOT 5
- Allow external impls of Bits and BitFlags HOT 12
- Reference actions by commit SHA HOT 2
- bitflags 2.3.0 breaks flags that refer to constants in separate impl blocks via `Self` HOT 1
- Clippy Lint Failures HOT 3
- Clippy warnings around "manual implementation of an assign operation" HOT 2
- Breaking change released as 2.3.0, which causes build failures on upgrade HOT 6
- Problems deriving serde after upgrading HOT 2
- Treatment of unknown bits in operators is inconsistent HOT 18
- Inconsistent debug output for flag with no bits HOT 4
- SWC - Update to 2.3.x causes incorrect output HOT 9
- Flagging supply-chain security issues HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitflags.