I want to define Ord for a custom type Point so it is sorted by the distance to the origin for Advent of Code 2019 day 10:
impl std::cmp::Ord for Point {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let this = self.x * self.x + self.y + self.y;
let that = other.x * other.x + other.y * other.y;
return this.cmp(&that);
}
}
However, I ran into this compile error:
= help: the trait
std::cmp::PartialOrdis not implemented forhelpers::models::Point
The documentation for PartialOrd only explains how to derive it or implement it. Those are pretty clear.
Why does Ord depend on this? What does the name Partial imply in the trait name? When will it get used?