-
Notifications
You must be signed in to change notification settings - Fork 288
PartialOrder with Rhs type parameter #565
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
Conversation
Change the `PartialOrder` trait to have an optional right-hand side type. This allows us to implement partial order for unequal types, which comes in handy when working with complex timestamp times that a container might store as a GAT instead of the actual type. Signed-off-by: Moritz Hoffmann <[email protected]>
179d6f7
to
b73e476
Compare
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.
Looks good, with a few light comments.
timely/src/progress/frontier.rs
Outdated
/// assert!(frontier.insert_or_else(&2, |x| *x)); | ||
/// assert!(!frontier.insert(3)); | ||
///``` | ||
pub fn insert_or_else<O: PartialOrder<T>, F: FnOnce(&O) -> T>(&mut self, element: &O, to_owned: F) -> bool where T: Clone + PartialOrder<O> { |
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.
Nit, but I think _or_else
isn't right, in that on insertion it does use the to_owned
function. What about insert_with
or something similar?
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.
Changed to insert_with
.
timely/src/progress/frontier.rs
Outdated
O: PartialOrder<T>, | ||
T: PartialOrder<O>, |
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.
One of these two is surprising, but I don't know which. Probably O: PartialOrder<T>
. With a time: &O
, surely we can compare the elements of self.frontier()
to time
just using T: PartialOrder<O>
?
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.
Yep, brain :fart: :)
where | ||
T: PartialOrder, | ||
O: PartialOrder<T>, | ||
T: PartialOrder<O>, |
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.
Similar as above; is one constraint unnecessary?
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.
Yep!
Signed-off-by: Moritz Hoffmann <[email protected]>
1df2749
to
4962a76
Compare
Add a
Rhs
parameter toPartialOrder
, to allow comparison between different types. This helps to compare types stored in containers in a different form than their original structure.