use std::cmp::Ordering;
#[derive(Clone, Copy, Default, Debug)]
pub struct Point {
pub x: usize,
pub y: usize,
}
impl Point {
pub fn new(x: usize, y: usize) -> Self {
Point { x, y }
}
}
impl Ord for Point {
fn cmp(&self, other: &Self) -> Ordering {
match self.y.cmp(&other.y) {
Ordering::Equal => self.x.cmp(&other.x),
o => o,
}
}
}
impl PartialOrd for Point {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl PartialEq for Point {
fn eq(&self, other: &Self) -> bool {
self.x == other.x && self.y == other.y
}
}
impl Eq for Point {}