use std::fmt;
use std::fmt::{Debug, Display};
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Point {
pub x: usize,
pub y: usize,
}
impl Display for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({},{})", self.x, self.y)
}
}
impl Debug for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self)
}
}
impl Point {
pub fn zero() -> Self {
Self { x: 0, y: 0 }
}
pub fn new(x: usize, y: usize) -> Self {
Self { x, y }
}
}
impl From<(usize, usize)> for Point {
fn from(value: (usize, usize)) -> Self {
Self { x: value.0, y: value.1 }
}
}
impl From<Point> for (usize, usize) {
fn from(value: Point) -> Self {
(value.x, value.y)
}
}