-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Should PartialOrd provide impl for Ord to avoid boilerplate? #63104
Comments
This conflicts with the existing blanket error[E0119]: conflicting implementations of trait `std::cmp::PartialOrd<&_>` for type `&_`:
--> src/lib.rs:3:1
|
3 | impl<T: Ord> PartialOrd for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<A, B> std::cmp::PartialOrd<&B> for &A
where A: std::cmp::PartialOrd<B>, A: ?Sized, B: ?Sized; (There was a previous discussion on reddit r/cpp) The idea is a good one, since the existing method of providing custom |
@shingtaklam1324 what this is basically saying is that given |
Pretty much. Essentially what
Consider a type
|
This has been a wish for a long time (such as rust-lang/rfcs#1028). I think it's better tracked in the RFCs repo, since it depends on languages changes, and is plausibly just a requirement to be addressed in a specialization RFC. (Or a different change, which would also take an RFC.) |
Currently
std
gives the following example in "How can I implementOrd
?":I was wondering why this boilerplate couldn't be reduced, because it seems clear that in almost all cases of
Ord
implementation,PartialOrd
implementation can be done in terms of the former.I suspect this is in its current state because it exists prior to specialization? If you have the following:
Am I right that the
std
example could be updated to:?
The text was updated successfully, but these errors were encountered: