-
Notifications
You must be signed in to change notification settings - Fork 276
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 PartialOrder impls #322
Conversation
That looks good. Maybe we could call the Thanks for taking the time to do this. |
Oh, that's a good idea. I'd be up for deprecating |
Yeah that would be even better, up to you |
@@ -157,6 +164,19 @@ impl<T: PartialOrder> Antichain<T> { | |||
#[inline] pub fn elements(&self) -> &[T] { &self.elements[..] } | |||
} | |||
|
|||
impl<T: PartialEq> PartialEq for Antichain<T> { | |||
fn eq(&self, other: &Self) -> bool { |
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.
not sure if it works here as I haven't tried, but.. can we just do self.elements() == other.elements()
? slice comparison should do the job.
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 has the defect that it doesn't equate two slices that have the same elements, but in a different order. I think this was one of the reasons that I shied away from the implementation in the first place, but it's probably worth fixing (as otherwise equality testing could return surprising results anyhow).
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 assumed they were sorted, but it's not the case.. also, how can you sort incomparable elements? ahah nvm, dumb comment
This PR adds
PartialOrder
implementations forAntichain
andAntichainRef
. The methodsless_equal
andless_than
clash with the per-time implementations (perhaps those should only be for antichains, which each singleton time is), but the inherent methods take priority in resolution, and this doesn't appear to cause any breakage.The intent here is to allow these types to implement
Lattice
in the differential crate, in the interest of tidying up a bunch of bespoke logic.cc @LorenzSelv