-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement RFC#28: Add PartialOrd::partial_cmp #15030
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
Test compilation failures:
|
JSON objects are unordered key-value maps, and I don't really like that we've extended it with ordering semantics based on key comparisons. I've only ever seen JSON objects mapped to hash tables, not ordered maps (except in C++98, where there was no standard hash table). I wouldn't worry much about trying to get that ordering right, because I don't think it's a good idea to be doing it in the first place. |
r=me when coretest is passing, thanks! |
It seems like the right way forward here is to extract libcore's tests to a separate crate. I'm working on that now, and this can go in on top of that. |
@@ -154,20 +160,57 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering { | |||
/// 5.11). | |||
#[lang="ord"] | |||
pub trait PartialOrd: PartialEq { | |||
/// This method returns an ordering between `self` and `other` values | |||
/// if one exists. | |||
#[cfg(stage0)] |
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.
Hm, why does this need staging?
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.
The snapshot's deriving won't generate partial_cmp
so there needs to be a default impl.
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.
Ah, tricky!
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. RFC: 0028-partial-cmp
@huonw updated |
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. # Note This isn't ready to merge yet since libcore tests are broken as you end up with 2 versions of `Option`. The rest should be reviewable though. RFC: 0028-partial-cmp
ci(metrics): Run measurement functions in parallel Resolves rust-lang#14853
I ended up altering the semantics of Json's PartialOrd implementation.
It used to be the case that Null < Null, but I can't think of any reason
for an ordering other than the default one so I just switched it over to
using the derived implementation.
This also fixes broken
PartialOrd
implementations forVec
andTreeMap
.Note
This isn't ready to merge yet since libcore tests are broken as you end up with 2 versions of
Option
. The rest should be reviewable though.RFC: 0028-partial-cmp