use std::cmp::Ordering;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub struct Position {
pub row: usize,
pub col: usize,
}
impl Position {
pub fn new(row: usize, col: usize) -> Self {
Self { row, col }
}
}
impl PartialOrd for Position {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Position {
fn cmp(&self, other: &Self) -> Ordering {
match self.row.cmp(&other.row) {
Ordering::Equal => self.col.cmp(&other.col),
x => x,
}
}
}