-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add impl of std::ops::Not
to bitmask_binop
#899
Conversation
Hm, I'm not sure what to make of this. I am usually worried about backwards compatibility (e.g. a new version of an extension introduces a new enum variant and then... that shouldn't change the meaning of existing code), but I can't come up with any case where this would actually break. What do others think? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #899 +/- ##
=======================================
Coverage 12.64% 12.65%
=======================================
Files 189 189
Lines 140456 140468 +12
=======================================
+ Hits 17767 17781 +14
+ Misses 122689 122687 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Uli Schlachter <[email protected]>
I just pushed the result of
@Syudagye Could you say something about "can be useful for manipulating this kind of data structure"? What manipulations did you have in mind exactly that isn't possible otherwise? |
I'm skeptical of adding more code to be generated, especially since the amount of code we already have is an issue for our downstream consumers. See #883 |
I'm currently trying to make an It may be possible to do this without the NOT operator, but i only see two way:
To me this is an expected operation on a mask, like
I don't know how much this affects build speeds, and if this is a concern i understand you are chasing every way to not make it worse. I could be mistaken though, i have no proper way of testing this other than build times.... |
Thanks for that input. That seems legitimate to me. Since I haven't written so before, what is my problem with this? In the XML, enums do not have an inherent size. So, whether an enum is backed by Since you only want I think I prefer only adding Edit: Random other crate calls this @notgull I know that we are in feature-creep-territory. However, the build time influence seems to be not much (in an unscientific benchmark). diff --git a/x11rb-protocol/src/x11_utils.rs b/x11rb-protocol/src/x11_utils.rs
index dcb22c12..c0a86a35 100644
--- a/x11rb-protocol/src/x11_utils.rs
+++ b/x11rb-protocol/src/x11_utils.rs
@@ -684,6 +684,11 @@ macro_rules! bitmask_binop {
pub fn bits(self) -> $u {
self.0
}
+
+ /// Foobar
+ pub fn difference(self, flag: impl Into<$u>) -> Self {
+ Self::from(<$u>::from(self) & !flag.into())
+ }
}
};
} |
Well, a |
Okay, I'm fine with adding it for now |
I opened #904 for that. |
With #904 merged, is that enough for closing this PR? Or is there still something missing? |
I'll go with the assumption that #904 superseded this one and everyone is happy with that outcome. Please speak up if my assumption is wrong. |
I noticed bitmasks (e.g.
EventMask
) was missing the!
operator, which can be useful for manipulating this kind of data structure.