-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Support operations for render layers and fix equality comparisons #13310
Support operations for render layers and fix equality comparisons #13310
Conversation
pub const fn and(self, other: Self) -> Self { | ||
let mask = self.0 & other.0; | ||
Self(mask) | ||
} | ||
|
||
/// Returns all [layers](Layer) included in either instance of [`RenderLayers`]. | ||
pub const fn or(self, other: Self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered calling these intersection
and union
for clarity, but I wasn't sure what to call xor using that naming convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the symmetric difference or disjunctive union. Pretty obscure so not sure it's worth switching. Note that Python does have a symmetric difference operation on sets. https://en.m.wikipedia.org/wiki/Symmetric_difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably is worth switching, at least to avoid potential confusion with the and
method. I imagine some people may think a.and(b)
means "all the layers from a and b"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the renaming.
if we can do #13317 would mean these can't be const, not sure how const-ness affects their value for you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! The bug you identify in without
potentially should make this included in 0.14
imo cc: @alice-i-cecile.
…3310) # Objective Allow combining render layers with a more-ergonomic syntax than `RenderLayers::from_iter(a.iter().chain(b.iter()))`. ## Solution Add the `or` operation (and corresponding `const` method) to allow computing the union of a set of render layers. While we're here, also added `and` and `xor` operations. Someone might find them useful ## Testing Added a simple unit test.
…vyengine#13310) # Objective Allow combining render layers with a more-ergonomic syntax than `RenderLayers::from_iter(a.iter().chain(b.iter()))`. ## Solution Add the `or` operation (and corresponding `const` method) to allow computing the union of a set of render layers. While we're here, also added `and` and `xor` operations. Someone might find them useful ## Testing Added a simple unit test.
…vyengine#13310) # Objective Allow combining render layers with a more-ergonomic syntax than `RenderLayers::from_iter(a.iter().chain(b.iter()))`. ## Solution Add the `or` operation (and corresponding `const` method) to allow computing the union of a set of render layers. While we're here, also added `and` and `xor` operations. Someone might find them useful ## Testing Added a simple unit test.
Objective
Allow combining render layers with a more-ergonomic syntax than
RenderLayers::from_iter(a.iter().chain(b.iter()))
.Solution
Add the
or
operation (and correspondingconst
method) to allow computing the union of a set of render layers. While we're here, also addedand
andxor
operations. Someone might find them usefulTesting
Added a simple unit test.