diff --git a/bracket-geometry/src/point.rs b/bracket-geometry/src/point.rs index e758cd26..1272c642 100755 --- a/bracket-geometry/src/point.rs +++ b/bracket-geometry/src/point.rs @@ -1,4 +1,5 @@ use std::convert::{From, TryInto}; +use std::fmt::Display; use std::ops; use ultraviolet::Vec2; @@ -6,7 +7,7 @@ use ultraviolet::Vec2; pub type PointF = Vec2; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash)] +#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash, Default)] /// Helper struct defining a 2D point in space. pub struct Point { /// The point's X location @@ -80,9 +81,9 @@ impl Point { } /// Converts the point to a usize tuple - /// + /// /// # Panics - /// + /// /// This can panic if X or Y are not convertible to a `usize`. #[must_use] pub fn to_unsigned_tuple(self) -> (usize, usize) { @@ -119,6 +120,12 @@ impl Point { */ } +impl Display for Point { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{},{}", self.x, self.y) + } +} + impl From<(i32, i32)> for Point { fn from(item: (i32, i32)) -> Self { Self {