-
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
default methods for the cmp traits #5590
Comments
@thestinger @msullivan do default methods work well enough for this yet? |
Not really. |
Default methods for |
I don't think this should be closed until all the implementations of the now-default methods have been deleted (just to ensure that the default methods are working). |
Also, the current default method implementation doesn't allow one to automatically get an |
Yeah, default methods don't quite work for what you want, and are not likely to. I think I"m going to close this. |
I think the following code works fine for this purpose. impl<T: TotalEq> Eq for T {
fn eq(&self, other: &T) -> bool { self.equals(other) }
}
impl<T: TotalOrd> Ord for T {
fn lt(&self, other: &T) -> bool { self.cmp(other) == Less }
} |
@alexcrichton thinks this is done; closing |
If there are specific instances which need to be switched over, there should be individual bugs for them at this point. I believe that the bulk of types which can benefit from default methods are currently benefiting from default methods. |
Fix ICE caused in unwrap module changelog: Fix ICE in unwrap module with unexpected number of parameters for method of Option/Result Fixes rust-lang#5579
(blocked on working default methods)
Implementing
TotalOrd
should implementOrd
with default methods, and implementingTotalEq
should provide a defaultEq
. Types with only a partial ordering can implementEq
/Ord
, and types with two different ordering semantics (floats) can implement both.A
TotalOrd
implementation can also provideTotalEq
via a default, so most types would only implement one trait directly or just derive everything.The text was updated successfully, but these errors were encountered: