If a non-generic type derives both PartialOrd and Ord, the PartialOrd impl can just do this:
impl PartialOrd for T {
fn_partial_cmp(&self, other: &T) {
Some(self.cmp(other))
}
}
(It won't work for generic types because the trait bounds on the generic parameters won't be right.)
This will likely be faster to compiler than a full implementation. It might also be a little easier for the backend to optimize.
Some futher discussion is on Zulip here.
If a non-generic type derives both
PartialOrdandOrd, thePartialOrdimpl can just do this:(It won't work for generic types because the trait bounds on the generic parameters won't be right.)
This will likely be faster to compiler than a full implementation. It might also be a little easier for the backend to optimize.
Some futher discussion is on Zulip here.